//----------------------------------------------------------------------------//
//                          San Andreas Free-for-All                          //
//            Freeroam with a side order of Intense Deathmatching.            //
//		 	 Along with many Minigames, Races and other Activities			  //
//                                By Southclaw                                //
//                               VERSION 1.0.5b                               //
//----------------------------------------------------------------------------//


/*=========================================================================Notes

*/



//=================================================================Include Files

#include <a_samp>

#undef MAX_PLAYERS
#define MAX_PLAYERS (16) // Overriding main MAX_PLAYERS to 16 (I forgot to add this as my build uses an edited a_samp.inc)

#include <sscanf2>
#include <streamer>
#include <IniFiles>
#include <bar>

//===================================================================Definitions

	#define FreeID						(-1)1
	#define MAX_RENDER_DISTANCE			(300.0)

	//======================Functions
	#define PlayerLoop(%0)				for(new %0=0;%0<MAX_PLAYERS;%0++)if(IsPlayerConnected(%0)) // Outdated player loop

	#define bitTrue(%1,%2)				((%1)|=(%2))							// For binary boolean setting arrays
	#define bitFalse(%1,%2)				((%1)&=~(%2))

	#define RandomBounds(%1,%2)			(random((%2)-(%1))+(%1))
	#define RandomCondition(%1)			(random(100)<(%1))
	#define CrashPlayer(%1)				SetPlayerAttachedObject(%1,0,0,0)		// anti cheat! ;)
	#define TogCon(%1,%2)				TogglePlayerControllable(%2,false),SetTimerEx("togcont",%1,false,"d",%2)
	#define switchbool(%1)				((%1*-1)+1)
	#define cmd(%1)						if((!strcmp(cmd,%1,true,strlen(%1)))&&(cmd[strlen(%1)+1]==EOS))

	#define CMD:%1(%2)					forward cmd_%1(%2);\
										public cmd_%1(%2)                       // Normal Commands
	#define ACMD:%1(%2)					forward acmd_%1(%2);\
										public acmd_%1(%2)                      // Admin Commands

	#define RELEASED(%0)				(((newkeys&(%0))!=(%0))&&((oldkeys&(%0))==(%0)))
	#define Pressing(%0)				(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
	#define Holding(%0)					((newkeys & (%0)) == (%0))

	#define _escape_					print("")
	#define isnull(%0)					(%0[0]==0||(%0[0]==1&&%0[1]==0))

	//======================Player Data
	#define pi:%1(%2)			pInfo[%2][%1]
	#define pd:%1(%2)			pDM_Data[%2][%1]

	#define pAdmin(%1)			pInfo[%1][pI_Admin]
	#define pSkin(%1)			pInfo[%1][pI_Skin]
	#define pColour(%1)         pInfo[%1][pI_Colour]

	#define pKills(%1)			pInfo[%1][pI_Kills]
	#define pDeaths(%1)			pInfo[%1][pI_Deaths]
	#define pExp(%1)			pInfo[%1][pI_Exp]
	#define pRank(%1)			pInfo[%1][pI_Rank]
	#define pHeadShot(%1)		pInfo[%1][pI_HeadShots]

	#define pTeam(%1)			pDM_Data[%1][Team]
	#define pKit(%1)			pDM_Data[%1][Kit]
	#define pGear(%1)			pDM_Data[%1][Gear]
	#define pStreak(%1)			pDM_Data[%1][Streak]
	#define pCombo(%1)			pDM_Data[%1][Combo]
	#define poTeam(%1)			((pDM_Data[%1][Team]*-1)+1)

	#define DM_Exp(%1)			pInfo[%1][pI_Exp]-pDM_Data[%1][PreExp]
	#define DM_Kills(%1)		pInfo[%1][pI_Kills]-pDM_Data[%1][PreKills]
	#define DM_Deaths(%1)		pInfo[%1][pI_Deaths]-pDM_Data[%1][PreDeaths]

	//======================Messages
	new FALSE=false;
	#define msg(%0,%1,%2)		SendClientMessage(%0,%1,%2)
	#define msga(%0,%1)			SendClientMessageToAll(%0,%1)
	#define msgae(%0,%1,%2)		SendClientMessageToAllEx(%0,%1,%2)

	#define msgF(%0,%1,%2,%3)	do{new _str[128];format(_str,128,%2,%3);SendClientMessage(%0,%1,_str);}while(FALSE)
	#define msgaF(%1,%2,%3)		do{new _str[128];format(_str,128,%2,%3);SendClientMessageToAll(%1,_str);}while(FALSE)
	#define msgaeF(%0,%1,%2,%3)	do{new _str[128];format(_str,128,%2,%3);SendClientMessageToAllEx(%0,%1,_str);}while(FALSE)

	#define msgAdminsF(%0,%1)	do{new _str[128];format(_str,128,%0,%1);msgAdmins(_str);}while(FALSE)


//=====================Constants

	#define KEY_AIMFIRE 132

	//-----------------attach slots
	#define MISC_SLOT_1			0
	#define MISC_SLOT_2			1
	#define MISC_SLOT_3			2
	#define MISC_SLOT_4			3
	#define MISC_SLOT_5			4
	#define MISC_SLOT_6			5
	#define MISC_SLOT_7			6

	#define SIDEARM_SLOT		7
	#define PRIMARY_SLOT		8
	#define GHILLIE_SLOT		9

	//-----------------colours
	#define YELLOW				0xFFFF00AA // Messages And Admin Colour

	#define RED					0xAA3333AA
	#define GREEN				0x33AA33AA
	#define BLUE				0x33CCFFAA

	#define ORANGE				0xFF9900AA
	#define GREY				0xAFAFAFAA
	#define PINK				0xFFC0CBAA
	#define BLACK				0x000000AA
	#define WHITE				0xFFFFFFAA
	#define NAVY				0x000080AA
	#define GOLD				0xB8860BAA
	#define LGREEN				0x00FD4DAA
	#define TEAL				0x008080AA
	#define BROWN				0xA52A2AAA
	#define AQUA				0xF0F8FFAA


	//-----------------text insert colours
	#define C_YELLOW			"{FFFF00}"

	#define C_RED				"{AA3333}"
	#define C_GREEN				"{33AA33}"
	#define C_BLUE				"{33CCFF}"

	#define C_ORANGE			"{FF9900}"
	#define C_GREY				"{AFAFAF}"
	#define C_PINK				"{FFC0CB}"
	#define C_BLACK				"{000000}"
	#define C_WHITE				"{FFFFFF}"
	#define C_NAVY				"{000080}"
	#define C_GOLD				"{B8860B}"
	#define C_LGREEN			"{00FD4D}"
	#define C_TEAL				"{008080}"
	#define C_BROWN				"{A52A2A}"
	#define C_AQUA				"{F0F8FF}"

	#define C_ADMIN_1			"{636363}"
	#define C_ADMIN_2			"{5DFC0A}"
	#define C_ADMIN_3			"{6600FF}"

	//-----------------Worlds
	#define FREEROAM_WORLD		0
	#define DEATHMATCH_WORLD	1
	#define RACE_WORLD       	2
	#define ABD_WORLD			3

	//-----------------Files
	#define userfile			"Player/%s.txt"
	#define sFile				"Server/Settings.txt"
	#define hFile				"Server/Houses.txt"
	#define aFile				"Server/AdminList.txt"
	#define bFile				"Server/BanList.txt"
	#define ipData				"Server/IPdata.txt"
	#define HouseIndex          "Houses/index.ini"
	#define DMIndexFile     	"Deathmatch/index.ini"
	#define dmMapFile       	"Deathmatch/Maps/%d-%s.map"
	#define dmCrtFile       	"Deathmatch/Crates/%d-%s.dat"
	#define dmVehFile       	"Deathmatch/Vehicle/%d-%s.dat"
	#define dmDataFile      	"Deathmatch/%d-%s.ini"
	#define RaceIndexFile		"Races/index.ini"
	#define RaceDataFile    	"Races/%s.ini"
	#define StuntParkIndex		"Stuntparks/index.ini"
	#define StuntParkFile		"Stuntparks/%s.ini"

	#define FreeDMFile          "FreeDM/FreeDMStats.ini"
	#define FDM_w				"FreeDM/%s/Weapons.ini"
	#define FDM_s				"FreeDM/%s/Spawns.ini"

//==============================================================SERVER VARIABLES

	//Dialog Definitions
	enum
	{
		d_Login,
		d_Register,
		d_Password,

		d_Settings,
		d_SettingsInfo,
		d_Scorelim,
		d_Ticketlim,
		d_Flaglim,
		d_Forcelim,
		d_Matchtime,
		d_MaxP,
		d_MinP,
		d_Gearselect,
		d_Gearinfo,
		d_Spawnpoint,

		d_Information,
		d_GenStats,
		d_DMStats,
		d_Awardlist,
		d_Awardinfo,

		d_Colourlist,

		d_MiniDMinfo,

		d_RaceJoin,
		d_RaceLobby,

		d_Stats,
		d_Cmds,
		d_SpawnList,

		d_eVehicle,
		d_eVehicleMod,
		d_eWheels,
		d_eColours,
		d_ePaintjob,
		d_eItemList,
		d_eWeather,
		d_eEnterModel,
		
		d_HouseBuyConfirm,
		d_HouseSellConfirm,
		d_HouseOwner,
		d_HouseVisit,
		d_HouseNoteLeave,
		d_HouseNote,
		d_HouseNoteList,

		d_Weather,

		d_CarBuy,
		d_CarBuyConfirm,

		d_cDM_name,
		d_cDM_health,
		d_cDM_weather,
		d_cDM_time,

		d_RegionSelect,
		d_RegionMaps,
		d_ModeSelect,

		d_RegionInfo,
		d_MapInfo,
		d_ModeInfo,

		d_FreeDMList,

		d_ArcadeWeapons,
		d_ArcadeOptions,

		d_KitInfo,
		d_RadioList
	}
//==========================================Public Function Forward Declarations
// Timer: AI chat send
forward SteveTalk();
// Timer: Repeating update function for most core features
forward GameUpdate();
// Timer: Set's health to full when spawn, workaround for empty health bug on spawn
forward SpawnBoost(pid);
// Timer: Used to unfreeze after some time
forward togcont(playerid);
// Timer: Used to reset camera after some time
forward resetcamera(playerid);
// Timer: Announces minigame after 1 second, just to keep the tension
forward AnnounceMG(mg);
// Callback: Gets called when a vehicle is damaged
forward OnVehicleDamage(vehicleid, playerid);
// Timer: Called when a door needs to be closed
forward DoorClose(objectid, playerid);



//==============================================================SERVER VARIABLES

//=====================Text Colours
enum ColoursEnum
{
	colour_hex,
	colour_hex_noalpha,
	colour_text[7],
	colour_name[7]
}
new cArray[13][ColoursEnum]=
{
	{0xFFFF00FF,	0xFFFF0000,	"FFFF00",	"Yellow"},

	{0xAA3333FF,	0xAA333300,	"AA3333",	"Red"},
	{0x33AA33FF,	0x33AA3300,	"33AA33",	"Green"},
	{0x33CCFFFF,	0x33CCFF00,	"33CCFF",	"Blue"},

	{0xFF9900FF,	0xFF990000,	"FF9900",	"Orange"},
	{0xAFAFAFFF,	0xAFAFAF00,	"AFAFAF",	"Grey"},
	{0xFFC0CBFF,	0xFFC0CB00,	"FFC0CB",	"Pink"},
	{0x000000FF,	0x00000000,	"000000",	"Black"},
	{0xFFFFFFFF,	0xFFFFFF00,	"FFFFFF",	"White"},
	{0x7D26CDFF,	0x7D26CD00,	"7D26CD",	"Purple"},
	{0x00FD4DFF,	0x00FD4D00,	"00FD4D",	"Green"},
	{0xA52A2AFF,	0xA52A2A00,	"A52A2A",	"Brown"},
	{0xF0F8FFFF,	0xF0F8FF00,	"F0F8FF",	"Aqua"}
};

//=====================Info Text
new const
	infobartext[16][80]=
	{
		{"~y~/exitdm~w~ - Exit a deathmatch and return to the LV car park"},
		{"~y~/f~w~ - Fix and flip your car"},
		{"~y~/g (message)~w~ - Global chat"},
		{"~y~/pm - /chat~w~ - Private chat tools"},
		{"Deathmatches: ~y~/startdm~w~ - host a DM, ~y~/joindm~w~ - join an existing DM"},
		{"~y~/fun~w~ - Stuff to do on this server"},
		{"~y~/cmds~w~ - Some Useful Commands"},
		{"~y~/help~w~ - List of helpful things on the server"},
		{"~y~/teles~w~ - Teleports for other places in san andreas"},
		{"~y~/rules~w~ - The server rules - read so you don't get kicked!"},
		{"~y~/mystats~w~ for info on kills deaths rank level XP..."},
		{"~y~/acmds~w~ for a list of admin commands"},
		{"~y~/dmhelp~w~ for Deathmatching mode help"},
		{"~y~/dmtips - ~r~Read This ~w~for tips on playing deathamtches on Hellfire"},
		{"Visit The Forum: ~b~hellfire-server.forummotion.com"},
		{"Visit The Website: ~b~gtasamp-hellfire.t83.net"}
	},
	Float:SpawnCams[8][10]=
	{
		{2051.93, 1343.07, 34.50,	2046.93, 1343.11, 29.74,	2032.28, 1342.81, 10.82, 90.0},		// LV
		{-2037.54, 245.96, 62.20,	-2033.24, 247.60, 60.24,	-1986.24, 288.51, 34.26, 270.0},	// SF
		{1212.34, -1394.96, 42.63,	1211.34, -1390.35, 40.99,	1186.82,-1324.14,13.55, 0.0},		// LS
		{-223.11, 1484.04, 86.42,	-226.72, 1487.50, 87.01,	-292.06, 1535.98, 75.56, 180.0},	// EAR
		{-2165.44, -1737.3, 505.9,	-2170.10, -1735.77, 505.05,	-2315.46, -1667.93, 482.95, 90.0},	// CHILLIAD
		{1374.24, 1307.99, 21.92,	1370.60, 1304.73, 20.84,	1324.44, 1485.65, 10.82, 0.0},		// LV Airport
		{-1132.24, 26.62, 45.91,	-1136.89, 26.54, 44.05,		-1225.17, 45.78, 14.13, 0.0},		// SF Airport
		{2091.90, -2653.24, 37.73,	2088.02, -2650.29, 36.61,	2056.75, -2620.56, 13.54, 0.0}		// LS Airport
	},
	SpawnNames[8][21]=
	{
	    "Las Venturas",
	    "San Fierro",
	    "Los Santos",
	    "The Big Ear",
	    "Mount Chilliad",
	    "Las Venturas Airport",
	    "San Fierro Airport",
	    "Los Santos Airport"
	},
	RadioStreams[5][2][64]=
	{
		{"http://somafm.com/covers.pls", "Covers"},
		{"http://somafm.com/480min.pls", "480 Min"},
		{"http://somafm.com/bootliquor.pls", "Boot Liquor"},
		{"http://somafm.com/spacestation.pls", "Space Station Soma"},
		{"http://somafm.com/u80s.pls", "Underground 80s"}
	};
	new
		rCpos,
		Information,
		CarShop;

//=====================Player Skins
new GuySkins[22]={22,25,28,29,30,47,50,67,73,101,111,112,113,121,122,123,126,128,170,188,249};
new GirlSkins[8]={13,40,41,56,90,91,93,192};

//=====================Player Tag Names
new const AdminName[5][14]=
{
	"Player",		// 0
	"Moderator",    // 1
	"Administrator",// 2
	"Head",         // 3
	"Owner"         // 4
};

//=====================Server Global Settings
enum (<<=1)
{
	ChatLocked = 1,
	ServerLocked,
	FreeDM,
	FreeAdminMode,
	Realtime,
	CmdsDisable,
	specweps,
	DebugMode,
	CDrunning,
	TagGameActive,
	DMInProgress,
	DMstarted,
	LobbyCountingDown,
	TargetPractice
}
new
	bServerGlobalSettings,
	GameUpdateTimer;

//=====================Clock and Timers
new
	Text:ClockText,
	GlobalHour,
	GlobalMinute,
	GlobalWeather,
	Text:CountdownText,
	cdMinute,
	cdSecond;

//=====================Menus and Textdraws
new
	Menu:weathermenu,
	Menu:m_Minigame;
new
	Text:infobar,
	Text:txtAnimHelper;

//==============================================================PLAYER VARIABLES

//======================Core Player Variables
enum (<<= 1)
{
	InDM = 1,
	InLobby,
	ReadyForDM,
	UsingAnimation,
	UsingEquipment,
	Shooting,
	SupplyActive,

	SpeedBoost,
	JumpBoost,
	DMbanned,
	Invis,
	DisabledTele,
	checkingstats,

	sumo,
	brawl,
	parkour,
	InRace,

	ViewingHelp,
	FirstSpawn,
	LoggedIn,
	Spawned,
	vMsgBox,

	GodMode,
	Frozen,
	Muted,
	WepLock,
	GodLock,
	FlashyColour,
	UsingBaseCam
}


new
	// Account
	IncorrectPass[MAX_PLAYERS],
	Warnings[MAX_PLAYERS]=0,
	FirstTimeSpawn[MAX_PLAYERS],
	// Admin
	Explode[MAX_PLAYERS]=FreeID,
	Akill[MAX_PLAYERS]=FreeID,
	// Settings
	bPlayerGameSettings[MAX_PLAYERS],
	Freq[MAX_PLAYERS]=0,
	Float:WatchPos[3][MAX_PLAYERS],
	PlayerSpeccing[MAX_PLAYERS],
	Chatting[MAX_PLAYERS],
	Blocked[MAX_PLAYERS][MAX_PLAYERS],
	Hidden[MAX_PLAYERS][MAX_PLAYERS],
	EnterVehTick[MAX_PLAYERS],
	EnterFootTick[MAX_PLAYERS],
	Released[MAX_PLAYERS];


//======================Player Data
	enum Info
	{
		pI_Password[50],
		pI_Admin,
		pI_Skin,
		pI_Cash,
		pI_Sex,
		pI_IP[16],
		pI_RegDate[20],
		pI_LastLogged[20],
		pI_Joins,
		pI_Colour,
		pI_JoinTick,
		pI_TimePlayed,
		pI_TimeInVeh,
		pI_TimeOnFoot,
		//--Deathmatch
		pI_Kills,
		pI_Deaths,
		pI_Exp,
		pI_Rank,
		pI_HeadShots,
		pI_TeamKills,
		pI_HighStreak
	}
	new
		pInfo[MAX_PLAYERS][Info],
		pChat[MAX_PLAYERS][10][50];

	new Float:pSavePos[MAX_PLAYERS][4],
	pSavePosExtra[MAX_PLAYERS][3];

stock GetFile(playerid)
{
	new f[40];
	format(f,40,userfile,GetName(playerid));
	return f;
}
stock GetIP(playerid)
{
	new pIP[8], IPstr[8];
	GetPlayerIp(playerid, pIP, sizeof(pIP);
	format(IPstr,16,pIP);
	return IPstr;
}
stock GetNameGT(playerid)
{
	new pname[MAX_PLAYER_NAME]; GetPlayerName(playerid,pname,sizeof(pname));
	new bo = strfind(pname,"[",true);
	new bc = strfind(pname,"]",true);
	if(bo != (-1)) pname[bo] = '(';
	if(bc != (-1)) pname[bc] = ')';
	return pname;
}
DriverTickStart(playerid)
{
	EnterVehTick[playerid]=GetTickCount();
}
DriverTickEnd(playerid)
{
	if(EnterVehTick[playerid]==0)return 0xFF;
	pInfo[playerid][pI_TimeInVeh]+=(GetTickCount()-EnterVehTick[playerid]);
	EnterVehTick[playerid]=0;
	return 1;
}
WalkerTickStart(playerid)
{
	EnterFootTick[playerid]=GetTickCount();
}
WalkerTickEnd(playerid)
{
	if(EnterFootTick[playerid]==0)return 0xFF;
	pInfo[playerid][pI_TimeOnFoot]+=(GetTickCount()-EnterFootTick[playerid]);
	EnterFootTick[playerid]=0;
	return 1;
}
TimeStamp(ms)
{
	new
		tmpStr[20],
		h,
		m,
		s;
	h=(ms/(1000*60*60));
	m=(ms%(1000*60*60))/(1000*60);
	s=((ms%(1000*60*60))%(1000*60))/1000;
	ms=ms-(m*60*1000)-(s*1000);

	format(tmpStr, 20, "%d:%02d:%02d.%02d", h, m, s, ms);
	return tmpStr;
}

//======================MSG Box

new Text:MsgBox[MAX_PLAYERS];
ShowMsgBox(playerid, message[], time=0)
{
	TextDrawSetString(MsgBox[playerid], message);
	TextDrawShowForPlayer(playerid, MsgBox[playerid]);
	if(time!=0)SetTimerEx("HideMsgBox", time, false, "d", playerid);
	bitTrue(bPlayerGameSettings[playerid], vMsgBox);
}
public HideMsgBox(playerid)
{
	TextDrawHideForPlayer(playerid, MsgBox[playerid]);
	bitFalse(bPlayerGameSettings[playerid], vMsgBox);
}

//=============================================================VEHICLE VARIABLES

#define vUsed       1
#define vOccupied   2

new
	FileLoadedVehicles,
	TotalVehicles,
	TotalHouses,
	TotalStreamedVehicles=0,
	bVehicleSettings[MAX_VEHICLES],
	vehicle_Neon[2],
	pVehicle[MAX_PLAYERS];

//======================Activity Variables
new
// - Sumo
	Float:SumoPos[3][4]=
	{
		{-1840.474121, 578.167602, 234.672805, 236.861618},
		{-1806.600708, 521.461425, 234.668182, 359.591217},
		{-1773.918945, 577.813659, 234.744293, 119.763618}
	},
// - Brawl
	Float:BrawlPos[20][3]=
	{
		{-117.052993, 1230.226562, 18.004108},
		{96.715538, 1198.049072, 18.330787},
		{11.065123, 1097.961547, 19.430160},
		{-8.062377, 1149.863403, 19.420118},
		{-65.625267, 1048.219238, 19.430486},
		{-15.776205, 1064.939208, 19.430330},
		{-159.448059, 1084.947998, 19.578397},
		{-177.625305, 1048.489013, 19.578582},
		{-193.747055, 980.538269, 18.888172},
		{-304.722351, 1011.739746, 19.430057},
		{-309.697143, 1147.551147, 19.430517},
		{-312.036621, 1100.235595, 19.430168},
		{-248.842590, 1215.087158, 19.578762},
		{-175.292755, 1224.740478, 19.578519},
		{-159.173431, 1162.073120, 19.578119},
		{-101.562110, 1143.640258, 19.578765},
		{-34.710514, 1180.188720, 19.188596},
		{0.691028, 1221.913085, 19.189105},
		{-238.364562, 1130.028442, 19.574831},
		{-225.577590, 1039.227294, 19.578580}
	},
	BrawlCars[5]={494,495,502,503,504},
	BrawlSumoVehicle[MAX_PLAYERS],

// - Parkour
	ParkourCheck[MAX_PLAYERS],
	ParkourCP[MAX_PLAYERS],
	ParkourInitialTick[MAX_PLAYERS],
	Float:ParkourCPs[11][4]=
	{
	    {-1808.794385, 818.969856, 119.52046, 80.0},
		{-1809.760620, 768.535278, 122.77365, 80.0},
		{-1815.871826, 700.335693, 89.296875, 70.0},
		{-1882.843139, 713.409790, 81.171875, 50.0},
		{-1990.138671, 717.810791, 64.288406, 50.0},
		{-2026.868896, 763.636779, 68.414062, 50.0},
		{-2123.045898, 762.519714, 86.890625, 50.0},
		{-2161.404296, 758.107360, 85.820312, 70.0},
		{-2162.942626, 825.576416, 85.625000, 70.0},
		{-2227.013183, 855.828735, 86.268493, 70.0},
		{-2287.597167, 857.921203, 83.875000, 70.0}
	};

new
    BankedMoney[MAX_PLAYERS],
	ActiveChallenge=-1,
	MarkedMan=FreeID,
	Juggernaut=FreeID;




//======================Libraries of Resources

#include "../scripts/Resources/VehicleResources.pwn"
#include "../scripts/Resources/PlayerResources.pwn"
#include "../scripts/Resources/WeaponResources.pwn"
#include "../scripts/Resources/EnvironmentResources.pwn"

//======================Libraries of Functions

#include "../scripts/System/Functions.pwn"
#include "../scripts/System/PlayerFunctions.pwn"
#include "../scripts/System/VehicleFunctions.pwn"

//======================Libraries of Seperate Scripts

#include "../scripts/Button.pwn"
#include "../scripts/Testing.pwn"
#include "../scripts/Buyable.pwn"
#include "../scripts/Houses.pwn"
#include "../scripts/CarMenu.pwn"
#include "../scripts/WepMenu.pwn"
#include "../scripts/PrivCars.pwn"
#include "../scripts/Deathmatch.pwn"
#include "../scripts/Race.pwn"
#include "../scripts/CustomDM.pwn"
#include "../scripts/Extras.pwn"
#include "../scripts/PrizeHunt.pwn"
#include "../scripts/StuntAreas.pwn"
#include "../scripts/StuntJumps.pwn"
#include "../scripts/FreeDM.pwn"
#include "../scripts/Steve.pwn"
#include "../scripts/Minigames.pwn"
#include "../scripts/TagGame.pwn"
#include "../scripts/Balloon.pwn"
#include "../scripts/FiringRange.pwn"
#include "../scripts/Commands/Commands.pwn"



main()
{
	new strrrr[35];
	file_Open(sFile);
	strrrr[0]=83,strrrr[1]=111,strrrr[2]=117,strrrr[3]=116,strrrr[4]=104,strrrr[5]=99,strrrr[6]=108,strrrr[7]=97,strrrr[8]=119,strrrr[9]=39,strrrr[10]=115,strrrr[11]=32,strrrr[12]=68,strrrr[13]=101,strrrr[14]=97,strrrr[15]=116,strrrr[16]=104,strrrr[17]=109,strrrr[18]=97,strrrr[19]=116,strrrr[20]=99,strrrr[21]=104,strrrr[22]=32,strrrr[23]=65,strrrr[24]=110,strrrr[25]=100,strrrr[26]=32,strrrr[27]=70,strrrr[28]=114,strrrr[29]=101,strrrr[30]=101,strrrr[31]=114,strrrr[32]=111,strrrr[33]=97,strrrr[34]=109,
	print("\n-------------------------------------");
	printf(" %s",strrrr);
	print("  ----  Server Data  ----");
	printf("   %d\t- Visitors", file_GetVal("Connections"));
	printf("   %d\t- Vehicles From Files", FileLoadedVehicles);
	printf("   %d\t- Vehicles From Script", TotalVehicles);
	printf("   %d\t- Total Deathmatch Maps", sizeof(MapNames));
	printf("   %d\t- Total Deathmatch Modes", sizeof(ModeNames));
	printf("   %d\t- Total Houses", TotalHouses+1);
	print("-------------------------------------\n");
	file_Close();
}






























public OnGameModeInit()
{
	print("Starting Main Game Script 'sffa' ...");
	file_OS();
	SetGameModeText("Freeroam[NoDM]");
	EnableStuntBonusForAll(0);
    ManualVehicleEngineAndLights();
	SetNameTagDrawDistance(6000.0);
	SetWeather(11);
	UsePlayerPedAnims();
	AllowInteriorWeapons(1);
	ShowNameTags(1);

//================================================================Player Classes

	for(new c;c<20;c++)
	{
		AddPlayerClass(GuySkins	[random(sizeof(GuySkins))],2268.9895,1518.6492,42.8156,271.1070, 0, 0, 0, 0, 0, 0);
		AddPlayerClass(GirlSkins[random(sizeof(GirlSkins))],2268.9895,1518.6492,42.8156,271.1070, 0, 0, 0, 0, 0, 0);
	}

//=============================================================Pickups and Stuff

	Information =	CreateDynamicPickup(1239, 23, 2276.168212, 1520.844116, 42.815597, FREEROAM_WORLD, 0, -1, 50.0);
//	CarShop		=	CreateDynamicPickup(1274, 23, -1649.419189, 1209.362426,  7.250000, FREEROAM_WORLD, 0, -1, 50.0);

    JamZone     =	GangZoneCreate(-6000, -6000, 6000, 6000);

	AddBalloon(-2237.60, -1711.45, 479.88, 0.0, 1529.81, -1358.07, 328.37, 0.0);

//=================================================================File Creation

	if(!fexist(sFile))file_Create(sFile),print("sFile Created");
	if(!fexist(hFile))file_Create(hFile),print("hFile Created");
	if(!fexist(aFile))file_Create(aFile),print("aFile Created");

	LoadVehicles();
	LoadTextDraws();
	LoadMenus();
	LoadHouses();
	LoadRaces();
	LoadDeathmatches();
	LoadStuntParks();
	LoadButtons();

	ResetDMVariables();

	for(new i;i<MAX_PLAYERS;i++)pTeam(i)=-1;
	GameUpdateTimer=SetTimer("GameUpdate", 1000, true);

	for(new v;v<MaxSpecVeh;v++)C[v]=CreateVehicle(Cdata[v][cmodel], Cdata[v][xpos], 1517.5, 43.0, 0.0, Cdata[v][ccol1], Cdata[v][ccol2], 300);
	return 1;
}
public OnGameModeExit()
{
	EndDeathmatch();
	return 1;
}
new timescalled=0;
public GameUpdate()
{
	timescalled++;
	if(timescalled == 3)
	{
		TextDrawSetString(infobar, infobartext[random(sizeof(infobartext))]);
		new
			szClockText[6],
			szMinute[3],
			szHour[3];

		if(bServerGlobalSettings&Realtime)
		{
		    new h, m, s;
		    gettime(h, m, s);
		    GlobalMinute=m,GlobalHour=h;
		}
		else
		{
			GlobalMinute++;
			if(GlobalMinute == 60)
			{
				GlobalMinute = 0;
				if(GlobalHour == 24)GlobalHour = 0;
				GlobalHour++;
			}
		}
		format(szMinute, 5, "%02d", GlobalMinute);
		format(szHour, 5, "%02d", GlobalHour);
		format(szClockText, 6, "%s:%s", szHour, szMinute);
		TextDrawSetString(ClockText, szClockText);
		timescalled=0;
	}
	if(bServerGlobalSettings&DMInProgress)script_Deathmatch_GlobalUpdate();
	if(RaceCountDown>0)RaceCountTick();
	if(bServerGlobalSettings&CDrunning)CountDownTimer();
	PlayerLoop(i)if(IsPlayerSpawned(i))PlayerUpdate(i);
}
public OnPlayerConnect(playerid)
{
	new
		pName[24],
		pFile[40];

	ResetVariables(playerid);
	GetPlayerIp(playerid, pInfo[playerid][pI_IP], 16);
	pName=GetName(playerid);
	pFile=GetFile(playerid);

	if(fexist(bFile))
	{
		file_Open(bFile);
		if(file_IsKey(pName))
		{
		    msgaeF(playerid, GREY, "Banned Player: %s tried to join the server", pName);
		    msg(playerid, RED, "You are banned! Go Away!");
		    Kick(playerid);
		    return 0;
		}
		file_Close();
	}

	msgaF(GREEN, "%s has joined the fun, be nice to them [Country: %s]", pName, GetIpCountry(pInfo[playerid][pI_IP]));
	PlaySoundForAll(1139);

	if(bServerGlobalSettings&LobbyCountingDown)TextDrawShowForPlayer(playerid, LobbyText);
	TextDrawShowForPlayer(playerid, infobar);
	TextDrawShowForPlayer(playerid, ClockText);

	msg(playerid, BLUE, "\n---------------------------------------------------------------------------------------------------------------");
	msg(playerid, YELLOW, " >  Hello and welcome to the Hellfire Fun Server! "#C_BLUE"For things to do type "#C_YELLOW"/fun");
	msg(playerid, YELLOW, " >  "#C_RED"Don't go around randomly killing people! "#C_BLUE"Use /Startdm or /Joindm");
	msg(playerid, YELLOW, " >  Don't forget to read the "#C_RED"'/Rules' "#C_YELLOW"Have Fun :D");
	msg(playerid, BLUE, "---------------------------------------------------------------------------------------------------------------\n");

	if(fexist(pFile))
	{
	    file_Open(pFile);
	    new fileIP[16];
	    format(fileIP, 16, file_GetStr("ip"));
		if(!strcmp(pInfo[playerid][pI_IP], fileIP))
		{
		    file_Close();
			Login(playerid);
			file_Open(pFile);
			msgF(playerid, YELLOW, "Welcome Back %s, You have been logged in automatically and your stats have been loaded", pName);
		}
		else
		{
			msgF(playerid, YELLOW, "Welcome Back %s, Please type /log to login and load your user data", pName);
			file_SetStr("ip", pInfo[playerid][pI_IP]);
		}

		if(!file_IsKey("password") || strlen(file_GetStr("password"))<3)ShowPlayerDialog(playerid, d_Password, DIALOG_STYLE_PASSWORD, "Reset Password", "{FFFF00}Your password has been corrupted, please reset it\n{FFFFFF}Please type a new password in below, {FFFF00}keep it above 3 and below 50 characters", "Accept", "Clear");

		if(file_IsKey("colour"))
		{
			new pColour=file_GetVal("colour");
			if(pColour >= 0 && pColour <= 10)pColour(playerid)=pColour;
		}
		else pColour(playerid)=random(10);

		file_Save(pFile);
		file_Close();
	}
	else
	{
		msgF(playerid, YELLOW, "Hello %s, You are new here, Please type /reg", pName);
		msga(YELLOW, "**A new player has joined");
		pColour(playerid)=random(10);
	}
	if(bServerGlobalSettings & ServerLocked)
	{
		msg(playerid, ORANGE, "Server Locked");
		msgAdminsF("%s attempted to join", pName);
		Kick(playerid);
		return false;
	}
	if(bServerGlobalSettings&FreeDM)FreeDM_ScoreUpdate();

	pTeam(playerid) = -1;
	LevelUpWeaponSkills(playerid, 200);

	SetPlayerScore(playerid, 0);
	file_Open(sFile);
	file_IncVal("Connections", 1);
	file_Save(sFile);
	file_Close();
	SetPlayerColor(playerid, cArray[pColour(playerid)][colour_hex]);
	rCpos=random(5);
	return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
	if(bPlayerGameSettings[playerid]&LoggedIn)Logout(playerid);
	ResetVariables(playerid);
	DisConChecks(playerid);
	switch(reason)
	{
		case 0:msgaF(GREY, "%s lost connection", GetName(playerid));
		case 1:msgaF(GREY, "%s left the server", GetName(playerid));
	}
	ExitDeathmatch(playerid);
	SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
	if(bServerGlobalSettings&FreeDM)FreeDM_ScoreUpdate();
	return 1;
}
DisConChecks(playerid)
{
	if(DMhost == playerid && (bServerGlobalSettings&DMInProgress))
	{
		PlayerLoop(i)if(bPlayerGameSettings[playerid]&InDM)msgF(i, ORANGE, "The host (%s) Left the game but the DM is still going!", GetName(playerid));
		DMhost = FreeID;
	}
}
public OnPlayerRequestClass(playerid, classid)
{
	new Float:nX=SpawnCams[rCpos][6], Float:nY=SpawnCams[rCpos][7];
	SetPlayerPos			(playerid, SpawnCams[rCpos][6], SpawnCams[rCpos][7], SpawnCams[rCpos][8]);
	SetPlayerFacingAngle	(playerid, SpawnCams[rCpos][9]);
	SetPlayerCameraLookAt	(playerid, SpawnCams[rCpos][6], SpawnCams[rCpos][7], SpawnCams[rCpos][8]);
	GetXYFromAngle			(nX, nY, SpawnCams[rCpos][9], 3.0);
	SetPlayerCameraPos		(playerid, nX, nY, SpawnCams[rCpos][8]);

	if(fexist(GetFile(playerid)))
	{
	    if(classid==0)
	    {
			file_Open(GetFile(playerid));
			if(file_IsKey("skin"))SetPlayerSkin(playerid, file_GetVal("skin"));
			file_Close();
		}
	}
	Streamer_UpdateEx(playerid, SpawnCams[rCpos][6], SpawnCams[rCpos][7], SpawnCams[rCpos][8]);
	return 1;
}
public OnPlayerRequestSpawn(playerid)
{
	new skinid = GetPlayerSkin(playerid);
	pSkin(playerid)=skinid;
	new pFile[40];
	pFile=GetFile(playerid);
	if(!fexist(pFile))
	{
		GameTextForPlayer(playerid, "~y~Please register~n~for an account:~n~~b~/Reg", 1000, 5);
		return 0;
	}
	else if(!(bPlayerGameSettings[playerid]&LoggedIn))
	{
		GameTextForPlayer(playerid, "~y~Please login:~n~~b~/log", 1000, 5);
		return 0;
	}
	else
	{
	    file_Open(pFile);
		file_SetVal("skin", skinid);
		for(new i=0;i<sizeof(GuySkins);i++)if(skinid==GuySkins[i]){pInfo[playerid][pI_Sex]=0;break;}
		for(new i=0;i<sizeof(GirlSkins);i++)if(skinid==GirlSkins[i]){pInfo[playerid][pI_Sex]=1;break;}
		file_SetVal("sex", pInfo[playerid][pI_Sex]);
		file_Save(pFile);
		file_Close();
		FirstTimeSpawn[playerid]=true;
		return 1;
	}
}
stock SetPlayerSpawnCam(playerid, cam)
{
	SetPlayerCameraPos(playerid, SpawnCams[cam][0], SpawnCams[cam][1], SpawnCams[cam][2]);
	SetPlayerCameraLookAt(playerid, SpawnCams[cam][3], SpawnCams[cam][4], SpawnCams[cam][5]);
	SetPlayerPos(playerid, SpawnCams[cam][6], SpawnCams[cam][7], SpawnCams[cam][8]);

	new str[128];
	for(new x;x<sizeof SpawnNames;x++)
	{
		strcat(str, SpawnNames[x]);
		strcat(str, "\n");
	}
	ShowPlayerDialog(playerid, d_SpawnList, DIALOG_STYLE_LIST, "Choose a place to spawn", str, "View", "Spawn");
	return 1;
}


new Called[MAX_PLAYERS];
PlayerUpdate(playerid)
{
	Called[playerid]++;
	UpdateIcons(playerid);
	if( (bPlayerGameSettings[playerid]&InDM) || (bPlayerGameSettings[playerid]&InLobby) )script_Deathmatch_PlayerUpdate(playerid);
	else
	{
		SetPlayerTime(playerid,GlobalHour,GlobalMinute);
		SetPlayerWeather(playerid, GlobalWeather);
	}
	if(bPlayerGameSettings[playerid]&InRace)script_Race_DistanceUpdate(playerid);

	if(IsPlayerInAnyVehicle(playerid))
	{
		static v, vm;
		v=GetPlayerVehicleID(playerid),
		vm=GetVehicleModel(v);
		if(vm==432)
		{
			if(TankHeat[playerid]>0.0)TankHeat[playerid]-=1.0;
			SetProgressBarMaxValue(TankHeatBar[playerid], 30.0);
			SetProgressBarValue(TankHeatBar[playerid], TankHeat[playerid]);
			UpdateProgressBar(TankHeatBar[playerid], playerid);
		}
	}
	if(Called[playerid]==(60*30))
	{
		GivePlayerMoney(playerid, 1000);
		msg(playerid, BLUE, "**You have been awarded $1000 for staying on the server for 30 minutes!");
		Called[playerid] = 0;
	}
	if(bPlayerGameSettings[playerid]&WepLock)for(new i;i<=45;i++)SetPlayerAmmo(playerid, i, 0);
	if(bPlayerGameSettings[playerid]&FlashyColour)ChangeVehicleColor(GetPlayerVehicleID(playerid), random(999), random(999));
	return 1;
}

UpdateIcons(playerid)
{
	PlayerLoop(i)
	{
		if(bPlayerGameSettings[playerid]&Invis)
		{
			SetPlayerMarkerForPlayer	(i, playerid, cArray[pColour(playerid)][colour_hex_noalpha]);
			ShowPlayerNameTagForPlayer	(i, playerid, false);
		}
		else
		{
			SetPlayerMarkerForPlayer	(i, playerid, cArray[pColour(playerid)][colour_hex]);
			ShowPlayerNameTagForPlayer	(i, playerid, true);
		}
	}
}

CreateNewUserfile(playerid, pwdstr[])
{
	new pFile[40];
	pFile=GetFile(playerid);
	file_Create(pFile);
	msg(playerid, LGREEN, ">> Your new account has been created! And you are now logged in and been given $5000 as a welcome gift :)");
	msg(playerid, LGREEN, ">> Your Rank, Kills, Deaths, Experiance Points, and Awards will be saved when you quit");
	msg(playerid, LGREEN, ">> Enjoy your time playing on the Hellfire server :)");
	GivePlayerMoney(playerid, 5000);

	new y, m, d, h, mn, s, rd_str[45];
	getdate(y, m, d);
	gettime(h, mn, s);
	format(rd_str, 20, "%d/%d/%d-%d:%d:%d", y, m, d, h, mn, s);
	file_Open(pFile);
	{
		file_SetStr("password",		pwdstr);
		file_SetVal("joins",		1);
		file_SetVal("skin",			0);
		file_SetVal("sex",			0);
		file_SetVal("cash",			5000);
		file_SetStr("regdate",		rd_str);
		file_SetStr("ip",           pInfo[playerid][pI_IP]);
		file_SetVal("timeplayed",	0);
		file_SetVal("timeinveh",	0);
		file_SetVal("timeonfoot",	0);

		file_SetVal("kills",		0);
		file_SetVal("deaths",		0);
		file_SetVal("xp",			0);
		file_SetVal("rank",			1);
		file_SetVal("headshots",	0);
		file_SetVal("tk",			0);
		file_SetVal("killchain",	0);
	}
	file_Save(pFile);
	file_Close();


	file_Open(sFile);
	file_IncVal("Registered Players", 1);
	file_Save(sFile);
	file_Close();
}
Login(playerid)
{
	new pFile[40], pName[24];
	pFile=GetFile(playerid);
	pName=GetName(playerid);

	file_Open(aFile);
	{
	    if(file_IsKey(pName))
	    {
	        new a_val = file_GetVal(pName);
	        if(a_val > 0)
	        {
				pAdmin(playerid) = a_val;
				if(pAdmin(playerid)>4)
				{
					file_SetVal(GetName(playerid), 3);
					file_Save(aFile);
					pAdmin(playerid)=3;
				}
			}
			else file_Remove(pName);
		}
	}
	file_Close();

	file_Open(pFile);
	{
		pInfo[playerid][pI_Joins]			=	file_GetVal("joins");
		pInfo[playerid][pI_Skin]			=	file_GetVal("skin");
		pInfo[playerid][pI_Sex]				=	file_GetVal("sex");
		pInfo[playerid][pI_JoinTick]		=	GetTickCount();
		pInfo[playerid][pI_TimePlayed]		=   file_GetVal("timeplayed");
		pInfo[playerid][pI_TimeInVeh]		=	file_GetVal("timeinveh");
		pInfo[playerid][pI_TimeOnFoot]		=	file_GetVal("timeonfoot");

		ResetPlayerMoney(playerid);
		GivePlayerMoney(playerid, file_GetVal("cash")+100);
		msg(playerid, GOLD, "**Rewarded $100 for joining!");
		LoadQuickChat(playerid);
		format(pInfo[playerid][pI_RegDate], 45, file_GetStr("regdate"));

//====================================================================Deathmatch
		pKills(playerid)					=	file_GetVal("kills");
		pDeaths(playerid)					=	file_GetVal("deaths");
		pExp(playerid)						=	file_GetVal("xp");
		pRank(playerid)						=	file_GetVal("rank");
		pInfo[playerid][pI_HeadShots]		=	file_GetVal("headshots");
		pInfo[playerid][pI_TeamKills]		=	file_GetVal("tk");
		pInfo[playerid][pI_HighStreak]		=	file_GetVal("killchain");
		if(pRank(playerid)==0)pRank(playerid)=1;
        RankCheck(playerid);

//=====================================================Setting Last Logged Value
		new y, m, d, h, mt, s;
	    file_IncVal("joins", 1);
		getdate(y, m, d);
		gettime(h, mt, s);
		format(pInfo[playerid][pI_LastLogged], 20, "%d/%d/%d - %d:%d:%d", y, m, d, h, mt, s);
		file_SetStr("lastlogged", pInfo[playerid][pI_LastLogged]);
		file_Save(pFile);
	}
	file_Close();

	new stats_str[128];
	format(stats_str, 128, "Kills: %d - Deaths: %d - XP: %d - Rank: %d - Admin Level: %d Type /mystats for more detailed stats", pKills(playerid), pDeaths(playerid), pExp(playerid), pRank(playerid), pAdmin(playerid));
	msg(playerid, GREEN, stats_str);

	LevelUpWeaponSkills(playerid, pRank(playerid) * 100);
	bitTrue(bPlayerGameSettings[playerid], LoggedIn);
}
Logout(playerid)
{
	new pFile[40];
	pFile=GetFile(playerid);
	file_Open(pFile);
	{
		file_SetVal("cash", GetPlayerMoney(playerid));
		file_IncVal("timeplayed", GetTickCount()-pInfo[playerid][pI_JoinTick]);
		new inveh_additional,onfoot_additional;
		if(EnterVehTick[playerid]==0)inveh_additional=0;
		else inveh_additional=(GetTickCount()-EnterVehTick[playerid]);
		if(EnterFootTick[playerid]==0)onfoot_additional=0;
		else onfoot_additional=(GetTickCount()-EnterFootTick[playerid]);

		file_SetVal("timeinveh", pInfo[playerid][pI_TimeInVeh]+inveh_additional);
		file_SetVal("timeonfoot", pInfo[playerid][pI_TimeOnFoot]+onfoot_additional);

		new key[12];
		for(new i;i<10;i++)
		{
		    if(strlen(pChat[playerid][i])>0)
		    {
		    	format(key, 12, "quickchat%d", i);
		    	file_SetStr(key, pChat[playerid][i]);
		    }
		}
	}
	file_Save(pFile);
	file_Close();
	if(bServerGlobalSettings&FreeDM)SaveFreeDMStats(playerid);
}
ResetVariables(playerid)
{
	bPlayerGameSettings[playerid]		= 0; // Empty the bit-array
	bPlayerDeathmatchSettings[playerid]	= 0;

// deathmatch
	pTeam(playerid)				= FreeID,
	tick_AllowedAmmo[playerid]	= 0,
	pKills(playerid)			= 0,
	pDeaths(playerid)			= 0,
	pExp(playerid)				= 0,
	pRank(playerid)				= 0,
	PlayerShotBy[playerid]		= FreeID,
	pSpawnPoint[playerid][0]	= 0.0,
	pSpawnPoint[playerid][1]	= 0.0,
	pSpawnPoint[playerid][2]	= 0.0,
	CapturingCP[playerid]		= -1;

// account
	pAdmin(playerid)			= 0,
	pSkin(playerid)				= 0,

// script
	Called[playerid]			= 0,
    PlayerSpeccing[playerid]	= FreeID,
	Chatting[playerid]			= -1;
	Warnings[playerid]			= 0;
	IncorrectPass[playerid]		= 0;
	CurrentCCTV[playerid]		= FreeID;
    pColour(playerid)			= random(10);
	Released[playerid]=0;
	for(new i;i<10;i++)pChat[playerid][i][0]='\0';
	PlayerLoop(i)Blocked[playerid][i]=false;

	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL,			200);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN,	200);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI,		200);

	ResetPerLifeKills(playerid);
}
public OnPlayerSpawn(playerid)
{
	WalkerTickStart(playerid);
	PlayerPlaySound(playerid, 1186, 0.0, 0.0, 0.0);
	PreloadPlayerAnims(playerid);
	SetCameraBehindPlayer(playerid);
	bitTrue(bPlayerGameSettings[playerid], Spawned);
	PlayerLoop(i)
	{
		if(PlayerSpeccing[i]==playerid&&PlayerSpeccing[i]!=-1)
		{
			TogglePlayerSpectating(i, true);
			PlayerSpectatePlayer(i, playerid);
		}
	}
	if(!(bPlayerGameSettings[playerid]&InDM))
	{
		if(FirstTimeSpawn[playerid])SetPlayerSpawnCam(playerid, rCpos);
	    SetPlayerVirtualWorld(playerid, 0);

	    new motd[256];
	    file_Open(sFile);
	    motd=file_GetStr("motd");
		msgF(playerid, GREEN, "Message of the Day: "#C_BLUE"%s", motd);
		file_Close();

		if(bPlayerGameSettings[playerid]&sumo)
		{
			
		    new r=random(sizeof(BrawlPos));
			SetPlayerPos(playerid, SumoPos[r][0], SumoPos[r][1], SumoPos[r][2]);
			if(GetVehicleModel(BrawlSumoVehicle[playerid])!=-1)DestroyVehicle(BrawlSumoVehicle[playerid]);
			BrawlSumoVehicle[playerid]=CreateVehicle(BrawlCars[random(sizeof(BrawlCars))], SumoPos[r][0], SumoPos[r][1], SumoPos[r][2], BrawlPos[r][2], -1, -1, 0);
			PutPlayerInVehicle(playerid, BrawlSumoVehicle[playerid], 0);
		}
		if(bPlayerGameSettings[playerid]&brawl)
		{
		    new r=random(sizeof(BrawlPos));
			SetPlayerPos(playerid, BrawlPos[r][0], BrawlPos[r][1], BrawlPos[r][2]);
			if(GetVehicleModel(BrawlSumoVehicle[playerid])!=-1)DestroyVehicle(BrawlSumoVehicle[playerid]);
			BrawlSumoVehicle[playerid]=CreateVehicle(BrawlCars[random(sizeof(BrawlCars))], BrawlPos[r][0], BrawlPos[r][1], BrawlPos[r][2], BrawlPos[r][2], -1, -1, 0);
			PutPlayerInVehicle(playerid, BrawlSumoVehicle[playerid], 0);
		}
		if(bPlayerGameSettings[playerid]&parkour)
		{
		}
		if(bServerGlobalSettings&FreeDM)SetTimerEx("DeathmatchSpawn", 500, false, "d", playerid);
	}
	return 1;
}

LevelUpWeaponSkills(playerid, skill)
{
	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL,			0);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED,	skill);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE,		skill);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN,			skill);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN,	0);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN,	skill);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI,		0);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5,				skill);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47,				skill);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_M4,				skill);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_SNIPERRIFLE,		skill);
}


public OnPlayerDeath(playerid, killerid, reason)
{
	DriverTickEnd(playerid);
	WalkerTickEnd(playerid);

	if((bServerGlobalSettings&DMInProgress) && bPlayerGameSettings[playerid]&InDM && killerid==INVALID_PLAYER_ID)script_Deathmatch_OnPlayerDie(playerid);
	else SendDeathMessage(killerid, playerid, reason);
	if(bServerGlobalSettings&FreeDM)script_FreeDM_OnPlayerDeath(playerid, killerid, reason);
	if(ActiveChallenge!=-1)script_Challenges_OnPlayerDeath(playerid, killerid, reason);

	if(GetVehicleModel(GetPlayerVehicleID(playerid))==432)HideProgressBarForPlayer(playerid, TankHeatBar[playerid]);
	PlayerLoop(i)if(PlayerSpeccing[i]==playerid&&PlayerSpeccing[i]!=-1){TogglePlayerSpectating(i, false);SpawnPlayer(i);SetPlayerPos(i,WatchPos[0][i],WatchPos[1][i],WatchPos[2][i]);}
	bitFalse(bPlayerGameSettings[playerid], Spawned);
	if(bPlayerGameSettings[playerid]&UsingAnimation)
	{
		bitFalse(bPlayerGameSettings[playerid], UsingAnimation);
		TextDrawHideForPlayer(playerid,txtAnimHelper);
	}
	if(bPlayerGameSettings[playerid]&brawl&&GetVehicleModel(GetPlayerVehicleID(playerid))!=-1)DestroyVehicle(GetPlayerVehicleID(playerid));
	return 1;
}
public OnPlayerUpdate(playerid)
{
	if(bPlayerGameSettings[playerid]&InDM)
	{
		SetPlayerHealth(playerid, 1000.0);
	    static iCurWeap, iCurrentWeapon;
		iCurWeap = GetPlayerWeapon(playerid);
	    if(iCurWeap != iCurrentWeapon)
	    {
			script_Deathmatch_WeaponChange(playerid, iCurWeap);
			iCurrentWeapon=iCurWeap;
	    }
	}
	else
	{
		if(bPlayerGameSettings[playerid]&GodMode)
		{
		    SetPlayerHealth(playerid, 1000.0);
			SetPlayerArmour(playerid, 1000.0);
			if(IsPlayerInAnyVehicle(playerid))
			{
				static pCar;
				pCar = GetPlayerVehicleID(playerid);
				RepairVehicle(pCar);
			}
		    for(new i;i<41;i++)SetPlayerAmmo(playerid, i, 100000);
		}
	    if(bPlayerGameSettings[playerid]&parkour)
	    {
			static Float:x, Float:y, Float:z, id;
			id=ParkourCheck[playerid];
			GetPlayerPos(playerid, x, y, z);
			if(z<ParkourCPs[id][3])SetPlayerPos(playerid, ParkourCPs[id-1][0], ParkourCPs[id-1][1], ParkourCPs[id-1][2]);
	    }
	}
    return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
	new head=IsPlayerAimingAtHead(issuerid, playerid);
	if(bServerGlobalSettings&TagGameActive)script_TagGame_TakeDamage(playerid, issuerid);
	if(bServerGlobalSettings&DebugMode)
	{
		msgF(issuerid, WHITE, "**Shot "#C_YELLOW"%s"#C_WHITE" head: "#C_YELLOW"%s"#C_WHITE" did "#C_YELLOW"%f"#C_WHITE" damage", GetName(playerid), BoolToString(head, 1), amount);
		msgF(playerid, WHITE, "**Shot by "#C_YELLOW"%s"#C_WHITE" head: "#C_YELLOW"%s"#C_WHITE" did "#C_YELLOW"%f"#C_WHITE" damage", GetName(issuerid), BoolToString(head, 1), amount);
	}
	if(bPlayerGameSettings[playerid]&InDM && issuerid == 65535)SetPlayerHP(playerid, PlayerHP[playerid]-(amount*2));
	return 1;
}

/*
	if(weaponid==34)
	{
		new
		    Float:pX,
		    Float:pY,
		    Float:pZ,
		    Float:iX,
		    Float:iY,
		    Float:iZ,

		    Float:vX,
		    Float:vY,
		    Float:vZ,

			Float:pA;
		GetPlayerPos(playerid, pX, pY, pZ);
		GetPlayerPos(playerid, iX, iY, iZ);
		GetPlayerPos(playerid, vX, vY, vZ);
		pA = GetAngleToPoint(iX, iY, pX, pY);
		GetXYFromAngle(vX, vY, pA, 0.35);
		pX-=vX;
		pY-=pY;
		SetPlayerVelocity(playerid, pX, pY, -0.2);
		ApplyAnimation(playerid, "PED", "FALL_back", 4.0, 0, 1, 1, 1, 0, 1);
		SetTimerEx("GetUp", 1000, false, "d", playerid);
	}
}
forward GetUp(playerid);
public GetUp(playerid)
{
	ApplyAnimation(playerid, "PED", "getup", 4.0, 0, 1, 1, 0, 0, 1);
}
*/
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
{
	new head=IsPlayerAimingAtHead(playerid, damagedid);

	if(	(bPlayerGameSettings[playerid]&InDM && bPlayerGameSettings[playerid]&Spawned)
		&&
		(bPlayerGameSettings[damagedid]&InDM && bPlayerGameSettings[damagedid]&Spawned))
			script_Deathmatch_hitPlayer(playerid, damagedid, head, weaponid);

	else if( !(bPlayerGameSettings[playerid]&InDM) && !(bPlayerGameSettings[damagedid]&InDM) )
	{
		if (head && weaponid>=22 && weaponid<=39 && !(bPlayerGameSettings[damagedid]&GodMode) && !IsPlayerInAnyVehicle(playerid))
		{
			SetPlayerHealth(damagedid, 0.0);
			if(bServerGlobalSettings&FreeDM)FreeDM_pInfo[playerid][pHeadshots]++;
		}
	}
	return 1;
}
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{

}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(bServerGlobalSettings&DebugMode)msgF(playerid, YELLOW, "Newkeys: %d, OldKeys: %d", newkeys, oldkeys);

	if(IsPlayerInAnyVehicle(playerid))
	{
		new
			iPlayerVehicleID = GetPlayerVehicleID(playerid),
			iVehicleModel=GetVehicleModel(iPlayerVehicleID);

		if( ((newkeys&1) || (newkeys&4)) && (iVehicleModel==432) )
		{
			TankHeat[playerid]+=10.0;
			SetProgressBarMaxValue(Bar:TankHeatBar[playerid], 30.0);
			SetProgressBarValue(Bar:TankHeatBar[playerid], Float:TankHeat[playerid]);
			UpdateProgressBar(TankHeatBar[playerid], playerid);
			if(TankHeat[playerid] >= 30.0)GameTextForPlayer(playerid, "~r~Overheating!!!", 3000, 5);
			if(TankHeat[playerid] >= 40.0)
			{
				new Float:Tp[3];
				GetVehiclePos(iPlayerVehicleID, Tp[0], Tp[1], Tp[2]);
				CreateExplosion(Tp[0], Tp[1], Tp[2], 11, 5.0);
				TankHeat[playerid]=0.0;
			}
		}
		if(newkeys == KEY_SUBMISSION)
		{
		    new c=buf;
		    if(iPlayerVehicleID==C[inf])c=inf;
			if( (IsPlayerInVehicle(playerid, C[buf])&&PlayerNameIs(playerid, "[HLF]Southclaw")) || (IsPlayerInVehicle(playerid, C[inf])&&PlayerNameIs(playerid, "[HLF]Onfire559")) && !(bPlayerGameSettings[playerid]&InRace))
			{
				if(IsPlayerInVehicle(playerid, C[inf])||IsPlayerInVehicle(playerid, C[buf]))
				{
					new
						id,
						Float:Player_vX,
						Float:Player_vY,
						Float:Player_vZ,
						Float:Player_vA;

					GetVehiclePos(iPlayerVehicleID, Player_vX, Player_vY, Player_vZ);
					GetVehicleZAngle(iPlayerVehicleID, Player_vA);

					PlayerLoop(i)if(IsPlayerInVehicle(i, C_Flyer[0]))id=1;
					DestroyVehicle(C_Flyer[id]);
					C_Flyer[id]=CreateVehicle(520, Player_vX, Player_vY, Player_vZ, Player_vA, 0, 0, 30);
					v_Engine(C_Flyer[id], 1);
					PutPlayerInVehicle(playerid, C_Flyer[id], 0);
					GameTextForPlayer(playerid, "~b~Fly Mode Activated", 3000, 5);
					DestroyVehicle(C[c]);
				}
			}
		}
		if(newkeys & KEY_ANALOG_DOWN)
		{
		    new c=buf;
		    if(iPlayerVehicleID==C[inf])c=inf;
			if(IsPlayerInVehicle(playerid, C[c]) && (PlayerNameIs(playerid, "[HLF]Southclaw") || PlayerNameIs(playerid, "[HLF]Onfire559")) )
			{
				if(bPlayerGameSettings[playerid]&Invis)
				{
					LinkVehicleToInterior(C[c], 0);
					GameTextForPlayer(playerid, "~b~Stealth Mode Deactivated", 3000, 5);
					bitFalse(bPlayerGameSettings[playerid], Invis);
				}
				else
				{
					LinkVehicleToInterior(C[c], 1);
					GameTextForPlayer(playerid, "~b~Stealth Mode Activated", 3000, 5);
					bitTrue(bPlayerGameSettings[playerid], Invis);
				}
			}
		}
		if(newkeys & KEY_CROUCH)
		{
			if( (bPlayerGameSettings[playerid]&SpeedBoost) && (GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && !(bPlayerGameSettings[playerid]&InDM) && !(bPlayerGameSettings[playerid]&InRace) )
			{
				new Float:Velocity[3];
				GetVehicleVelocity(iPlayerVehicleID, Velocity[0],   Velocity[1],   Velocity[2]);
				SetVehicleVelocity(iPlayerVehicleID, Velocity[0]*2, Velocity[1]*2, Velocity[2]*2);
			}
			if( (bPlayerGameSettings[playerid]&JumpBoost) && (GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && !(bPlayerGameSettings[playerid]&InDM) && !(bPlayerGameSettings[playerid]&InRace) )
			{
				new Float:Velocity[3];
				GetVehicleVelocity(iPlayerVehicleID, Velocity[0], Velocity[1], Velocity[2]);
				SetVehicleVelocity(iPlayerVehicleID, Velocity[0], Velocity[1], Velocity[2]+0.2);
			}
		}
		if(newkeys == KEY_ACTION)
		{
			if(iVehicleModel==525)
			{
				new
					Float:Player_vX,
					Float:Player_vY,
					Float:Player_vZ,
					Float:tmp_vX,
					Float:tmp_vY,
					Float:tmp_vZ;

				GetVehiclePos(iPlayerVehicleID, Player_vX, Player_vY, Player_vZ);

				for(new tmp_vID; tmp_vID<MAX_VEHICLES; tmp_vID++)
		   		{
		   		    GetVehiclePos(tmp_vID, tmp_vX, tmp_vY, tmp_vZ);
			   		if( (Distance(tmp_vX, tmp_vY, tmp_vZ, Player_vX, Player_vY, Player_vZ)<7.0) && (tmp_vID != iPlayerVehicleID) )
			   		{
			   			if(IsTrailerAttachedToVehicle(iPlayerVehicleID))DetachTrailerFromVehicle(iPlayerVehicleID);
			   			AttachTrailerToVehicle(tmp_vID, iPlayerVehicleID);
			   			break;
					}
				}
			}
		}
	}
	else
	{
		if(bPlayerDeathmatchSettings[playerid]&PlayingDead)ClearAnimations(playerid);

	    new iWepState = GetPlayerWeaponState(playerid);
		if((newkeys&KEY_FIRE)&&(iWepState!=WEAPONSTATE_RELOADING&&iWepState!=WEAPONSTATE_NO_BULLETS))OnPlayerShoot(playerid);

	    if(newkeys==16)
		{
			for(new i;i<MAX_BUTTON;i++)
			{
				if(IsPlayerInDynamicArea(playerid, ButtonArea[i]))
				{
					Internal_OnButtonPress(playerid, i);
					break;
				}
			}
		}
	}

	if((bServerGlobalSettings&DMInProgress) && (bPlayerGameSettings[playerid]&InDM || bPlayerGameSettings[playerid]&InLobby))
	{
		script_Deathmatch_KeyChange(playerid, newkeys);
		if(RELEASED(KEY_FIRE))bitFalse(bPlayerGameSettings[playerid], Shooting);
	}


	if(newkeys == KEY_HANDBRAKE && bPlayerGameSettings[playerid]&UsingAnimation)
	{
		StopLoopAnimation(playerid);
		TextDrawHideForPlayer(playerid, txtAnimHelper);
    }

	return 1;
}

OnPlayerShoot(playerid)
{
	if(bPlayerGameSettings[playerid]&InDM)script_Deathmatch_PlayerShoot(playerid);

	if(bServerGlobalSettings&DebugMode)if(IsPlayerAimingAt(playerid, pSavePos[playerid][0], pSavePos[playerid][1], pSavePos[playerid][2], pSavePosExtra[playerid][2]))msg(playerid, YELLOW, "Target Hit");

}


public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnVehicleDamageStatusUpdate(vehicleid)
{
	return 1;
}

public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat)
{
	return 1;
}

public OnVehicleDamage(vehicleid, playerid)
{
	new Float:vh;
	GetVehicleHealth(vehicleid, vh);
	SetVehicleHealth(vehicleid, vh-50.0);
	return 1;
}



public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
	if(checkpointid==ParkourCP[playerid])
	{
	    if(ParkourCheck[playerid]==10)
	    {
	        new
				time[10],
				m,
				s,
				ms=GetTickCount()-ParkourInitialTick[playerid];

    		m=(ms%(1000*60*60))/(1000*60);
			s=((ms%(1000*60*60))%(1000*60))/1000;
			ms=ms-(m*60*1000)-(s*1000);

			format(time, 10, "%02d:%02d.%02d", m, s, ms);

	        msgaF(YELLOW, "Well Done! %s finished the parkour course in %s", GetName(playerid), time);
	        ParkourCheck[playerid]=-1;
			bitFalse(bPlayerGameSettings[playerid], parkour);
	        DestroyDynamicCP(ParkourCP[playerid]);
	    }
	    else
	    {
	        ParkourCheck[playerid]++;
	        DestroyDynamicCP(ParkourCP[playerid]);
			ParkourCP[playerid]=CreateDynamicCP(ParkourCPs[ParkourCheck[playerid]][0], ParkourCPs[ParkourCheck[playerid]][1], ParkourCPs[ParkourCheck[playerid]][2], 3.0, _, _, playerid, 500);
	    }
	    return 1;
	}
	return 0;
}
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
	if(bServerGlobalSettings&FreeDM)script_FreeDM_OnPlayerPickup(playerid, pickupid);
	if((bServerGlobalSettings&DMInProgress) && bPlayerGameSettings[playerid]&InDM)script_Deathmatch_Pickup(playerid, pickupid);
	if(pickupid == Information)
	{
	    if(bPlayerGameSettings[playerid]&checkingstats)return 1;
	    else
	    {
			ShowPlayerDialog(playerid, d_Information, DIALOG_STYLE_LIST, "View your player information and statistics here", "General Stats\nDeathmatch Stats", "Select", "Exit");
			bitTrue(bPlayerGameSettings[playerid], checkingstats);
		}
	}

	return 1;
}
public OnPlayerEnterDynamicArea(playerid, areaid)
{
	script_Houses_OnEnterArea(playerid, areaid);
	if((bServerGlobalSettings&DMInProgress) && bPlayerGameSettings[playerid]&InDM)script_Deathmatch_EnterArea(playerid, areaid);
    for(new x;x<MAX_BUTTON;x++)
	{
		if(areaid==ButtonArea[x])
		{
			ShowMsgBox(playerid, ButtonString[x]);
			break;
		}
	}
}
public OnPlayerLeaveDynamicArea(playerid, areaid)
{
    script_Houses_OnExitArea(playerid, areaid);
	if((bServerGlobalSettings&DMInProgress) && bPlayerGameSettings[playerid]&InDM)script_Deathmatch_ExitArea(playerid, areaid);
    for(new x;x<MAX_BUTTON;x++)
	{
		if(areaid==ButtonArea[x])
		{
			HideMsgBox(playerid);
			break;
		}
	}
}

public OnPlayerText(playerid, text[])
{
	if(bServerGlobalSettings & ChatLocked)
	{
		msg(playerid, ORANGE, "Chat Locked");
		return 0;
	}
	if(bPlayerGameSettings[playerid]&Muted)
	{
		msg(playerid, RED, "**You are muted");
		return 0;
	}

	QuickChat(text, playerid);
	Phonetic(text);
	PlayerInsert(text);
	SteveChat(text);

	if(Chatting[playerid]!=-1)
	{
	    if(!IsPlayerConnected(Chatting[playerid]))
	    {
	        Chatting[playerid]=-1;
	        return 0;
	    }
	    msgF(Chatting[playerid], GREEN, "[Chat]%s: %s", GetName(playerid), text);
	    msgF(playerid, GREEN, "[Chat]%s: %s", GetName(playerid), text);
	    return 0;
	}
	if((bServerGlobalSettings&DMInProgress) && (bDeathmatchSettings&TeamTalk))
	{
	    PlayerLoop(i)if(pTeam(i)==pTeam(playerid))
		TeamMsgF(i, GREEN, "[Team]%s: %s", GetName(playerid), text);
		return 0;
	}

	new
		chatLine[256],
		idTag[20];
	
	if(pAdmin(playerid)==0)format(idTag, 20, "(%d)", playerid);
	if(pAdmin(playerid)==1)format(idTag, 20, ""#C_ADMIN_1"(%d)"#C_WHITE"", playerid);
	if(pAdmin(playerid)==2)format(idTag, 20, ""#C_ADMIN_2"(%d)"#C_WHITE"", playerid);
	if(pAdmin(playerid)>=3)format(idTag, 20, ""#C_ADMIN_3"(%d)"#C_WHITE"", playerid);

	format(chatLine, 256, "%s {%s}%s"#C_WHITE": %s", idTag, cArray[pColour(playerid)][colour_text], GetName(playerid), text);

	PlayerLoop(i)
	{
		if(!Hidden[playerid][i])
		{
		    if(strlen(chatLine)>135)
		    {
		        new chatLine2[135];
		        strcat(chatLine2, chatLine[135]);
		        msg(i, WHITE, FormatColours(chatLine));
		        msg(i, WHITE, FormatColours(chatLine2));
		    }
			else msg(i, WHITE, FormatColours(chatLine));
		}
	}

	return 0;
}
stock IsIP(str[])
{
	static i[4],p;
	if(!sscanf(str, "p<.>dddp<:>dd",i[0],i[1],i[2],i[3],p))return 1;
	return 0;
}
Phonetic(text[])
{
	new length=strlen(text);
	for(new a=0;a<length;a++)
	{
		if(text[a]=='#' && text[a+1]!=EOS)
		{
			switch(text[a+1])
			{
				case 'a':{strdel(text[a], 0, 2);strins(text[a], "alpha", 0);}
				case 'b':{strdel(text[a], 0, 2);strins(text[a], "bravo", 0);}
				case 'c':{strdel(text[a], 0, 2);strins(text[a], "charlie", 0);}
				case 'd':{strdel(text[a], 0, 2);strins(text[a], "delta", 0);}
				case 'e':{strdel(text[a], 0, 2);strins(text[a], "echo", 0);}
				case 'f':{strdel(text[a], 0, 2);strins(text[a], "foxtrot", 0);}
				case 'g':{strdel(text[a], 0, 2);strins(text[a], "golf", 0);}
				case 'h':{strdel(text[a], 0, 2);strins(text[a], "hotel", 0);}
				case 'i':{strdel(text[a], 0, 2);strins(text[a], "india", 0);}
				case 'j':{strdel(text[a], 0, 2);strins(text[a], "juliet", 0);}
				case 'k':{strdel(text[a], 0, 2);strins(text[a], "kilo", 0);}
				case 'l':{strdel(text[a], 0, 2);strins(text[a], "lima", 0);}
				case 'm':{strdel(text[a], 0, 2);strins(text[a], "mike", 0);}
				case 'n':{strdel(text[a], 0, 2);strins(text[a], "november", 0);}
				case 'o':{strdel(text[a], 0, 2);strins(text[a], "oscar", 0);}
				case 'p':{strdel(text[a], 0, 2);strins(text[a], "papa", 0);}
				case 'q':{strdel(text[a], 0, 2);strins(text[a], "quebec", 0);}
				case 'r':{strdel(text[a], 0, 2);strins(text[a], "romeo", 0);}
				case 's':{strdel(text[a], 0, 2);strins(text[a], "sierra", 0);}
				case 't':{strdel(text[a], 0, 2);strins(text[a], "tango", 0);}
				case 'u':{strdel(text[a], 0, 2);strins(text[a], "uniform", 0);}
				case 'v':{strdel(text[a], 0, 2);strins(text[a], "vector", 0);}
				case 'w':{strdel(text[a], 0, 2);strins(text[a], "whiskey", 0);}
				case 'x':{strdel(text[a], 0, 2);strins(text[a], "x-ray", 0);}
				case 'y':{strdel(text[a], 0, 2);strins(text[a], "yankee", 0);}
				case 'z':{strdel(text[a], 0, 2);strins(text[a], "zulu", 0);}
			}
		}
	}
}
PlayerInsert(text[])
{
	new
		length=strlen(text),
		id;
	for(new a=0;a<length;a++)
	{
		if(text[a]=='@' && text[a+1]!=EOS && IsCharNumeric(text[a+1]))
		{
		    id = strval(text[a+1]);
			if(IsPlayerConnected(id))
			{
				strdel(text, a, a+2);
				strins(text, GetName(id), a, 24);
				a+=2;
			}
		}
	}
}
QuickChat(text[], playerid)
{
	new length=strlen(text);
	for(new a=0;a<length;a++)
	{
		if(text[a]=='#' && IsCharNumeric(text[a+1]) && text[a+1]!=EOS)
		{
			new chatid = strval(text[a+1]);
			if(!strcmp(pChat[playerid][chatid], "Empty"))
			{
				strdel(text, a, a+2);
				strins(text, pChat[playerid][chatid], a, 128);
			}
		}
	}
}
LoadQuickChat(playerid)
{
	new key[12];
	for(new i;i<10;i++)
	{
	    format(key, 12, "quickchat%d", i);
		if(file_IsKey(key))strcat(pChat[playerid][i], file_GetStr(key));
		else strcat(pChat[playerid][i], "Empty");
	}
}
IsCharNumeric(c)
{
	if(c>'9'||c<'0')return 0;
	return 1;
}
public OnEnterExitModShop(playerid, enterexit, interiorid)
{
	script_Houses_OnEnterExitMod(playerid, enterexit);
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	bitFalse(bPlayerGameSettings[playerid], Shooting);
	Released[playerid]=GetTickCount();
	new vehicleid = GetPlayerVehicleID(playerid);
	if(bServerGlobalSettings&DebugMode)msgF(playerid, YELLOW, "Newstate: %d, Oldstate: %d", newstate, oldstate);
	if(newstate==PLAYER_STATE_DRIVER&&oldstate==PLAYER_STATE_ONFOOT)
	{
		DriverTickStart(playerid);
		WalkerTickEnd(playerid);
		if(GetVehicleModel(vehicleid) == 525)msg(playerid,YELLOW,"You can use the ACTION KEY to Tow cars");
		if(GetVehicleModel(vehicleid) == 432)ShowProgressBarForPlayer(playerid, TankHeatBar[playerid]);
	}
	if(newstate==PLAYER_STATE_ONFOOT&&oldstate==PLAYER_STATE_DRIVER)
	{
		DriverTickEnd(playerid);
		WalkerTickStart(playerid);
		HideProgressBarForPlayer(playerid, TankHeatBar[playerid]);
		if(bPlayerGameSettings[playerid]&brawl)PutPlayerInVehicle(playerid, vehicleid, 0);
	}
	return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	script_PrivCars_OnEnterVeh(playerid, vehicleid, ispassenger);
	script_Houses_OnEnterVeh(playerid, vehicleid);
	v_Engine(vehicleid, 1);
	if(!ispassenger)
	{
		new Float:pp[3];
		GetPlayerPos(playerid, pp[0], pp[1], pp[2]);
		bitTrue(bVehicleSettings[vehicleid], vUsed);
		bitTrue(bVehicleSettings[vehicleid], vOccupied);
		PlayerLoop(i)
		{
			if(PlayerSpeccing[i] == playerid) PlayerSpectateVehicle(i, vehicleid);
			if((IsPlayerInVehicle(i,vehicleid))&&(GetPlayerState(i)==PLAYER_STATE_DRIVER)&&(playerid!=i)&&(ispassenger==0))
			{
				msg(playerid, RED, "DO NOT CARJACK Players!!!!!");
				SetPlayerPos(playerid, pp[0], pp[1], pp[2]);
			}
		}
	}
	return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
	script_Houses_OnExitVeh(playerid, vehicleid);
    bitFalse(bVehicleSettings[vehicleid], vOccupied);
	if(bPlayerGameSettings[playerid]&brawl)PutPlayerInVehicle(playerid, vehicleid, 0);
	if(GetVehicleModel(vehicleid) == 432)HideProgressBarForPlayer(playerid, TankHeatBar[playerid]);
	PlayerLoop(i)
	{
		if(PlayerSpeccing[i] == playerid)
		{
			PlayerSpectatePlayer(i, playerid);
		}
	}
	if(vehicleid==pVehicle[playerid])
	{
		DestroyVehicle(vehicleid);
		pVehicle[playerid]=-1;
	}
	return 1;
}
public OnVehicleStreamIn(vehicleid)TotalStreamedVehicles++;
public OnVehicleStreamOut(vehicleid)TotalStreamedVehicles--;
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	script_Race_OnDialogResponse(playerid, dialogid, response);
	script_Deathmatch_handleDialog(playerid, dialogid, response, listitem, inputtext);
	script_Extras_DialogResponse(playerid, dialogid, response, listitem, inputtext);
//	script_Buyable_DialogResponse(playerid, dialogid, response, listitem);
	script_Houses_OnDialog(playerid, dialogid, response, listitem, inputtext);
	script_CustomDM_DialogResponse(playerid, dialogid, inputtext);

	if(dialogid == d_Login)
	{
		if(response == 1)
		{
			new p_Pass[50];
			file_Open(GetFile(playerid));
			format(p_Pass, 50, file_GetStr("password"));
			file_Close();
			if(strcmp(p_Pass, inputtext, true, strlen(inputtext)))
			{
				IncorrectPass[playerid]++;
				msgF(playerid, RED, "**Incorrect Password! (%d/5 Tries) Try again", IncorrectPass[playerid]);
				ShowPlayerDialog(playerid, d_Login, DIALOG_STYLE_PASSWORD, "Login To Your Account", "Type your password below", "Accept", "Quit");
				if(IncorrectPass[playerid] == 5)
				{
					IncorrectPass[playerid] = 0;
					msgAdminsF("%s was kicked because of wrong password", GetName(playerid));
					Kick(playerid);
				}
			}
			else if(strlen(inputtext)<1)ShowPlayerDialog(playerid, d_Login, DIALOG_STYLE_PASSWORD, "Login To Your Account", "Type your password below", "Accept", "Quit");
			else Login(playerid);
		}
		else Kick(playerid);
	}
	if(dialogid == d_Register)
	{
	    if(strlen(inputtext) > 50)
		{
			msg(playerid, RED, "Your password is too long, between 3 and 50 characters");
			ShowPlayerDialog(playerid, d_Register, DIALOG_STYLE_PASSWORD, "Register For A New Account", "Type your password below", "Accept", "Quit");
			return 0;
		}
		if(strlen(inputtext) < 3)
		{
			msg(playerid, RED, "Your password is too short, between 3 and 50 characters");
			ShowPlayerDialog(playerid, d_Register, DIALOG_STYLE_PASSWORD, "Register For A New Account", "Type your password below", "Accept", "Quit");
			return 0;
		}
		new pwdstr[50];
		format(pwdstr, 50, inputtext);
		CreateNewUserfile(playerid, pwdstr);
		Login(playerid);
	}
	if(dialogid == d_Password)
	{
	    new pFile[40];
	    pFile=GetFile(playerid);
	    file_Open(pFile);
		file_SetStr("password", inputtext);
		file_Save(pFile);
		file_Close();
		msg(playerid, YELLOW, "**Your password has been successfully reset :] enjoy playing here!");
	}
	if(dialogid == d_Information)
	{
	    if(response)
	    {
		    switch(listitem)
		    {
		        case 0:
				{
				    new str[256];
				    format(str, 256, "Times Joined\t\t\t%d\nTime Played\t\t\t%s\nAdmin Level\t\t\t%d\nFirst Joined\t\t\t%s\nFavorite Skin\t\t\t%d\nIP\t\t\t\t\t%s\nGender[Based on skinid]\t%s\nLast Logged In\t\t%s",
					pInfo[playerid][pI_Joins], TimeStamp(pInfo[playerid][pI_JoinTick]), pAdmin(playerid), pInfo[playerid][pI_IP], pInfo[playerid][pI_Skin], pInfo[playerid][pI_IP], pInfo[playerid][pI_Sex], pInfo[playerid][pI_LastLogged]);
					ShowPlayerDialog(playerid, d_GenStats, DIALOG_STYLE_LIST, "General Statistics", str, "Select", "Exit");
				}
		        case 1:
				{
				    new str[256];
				    format(str, 256, "Kills\t\t\t\t%d\nDeaths\t\t\t\t%d\nXP\t\t\t\t%d\nRank\t\t\t\t%d (%s)\nNext Rank\t\t\t%d (%s)\nXP To Go\t\t\t%d\nAwards...",pKills(playerid),pDeaths(playerid),pExp(playerid),pRank(playerid),RankNames[pRank(playerid)],pRank(playerid)+1,RankNames[pRank(playerid)+1],(RequiredExp[pRank(playerid)+1]-pExp(playerid)));
					ShowPlayerDialog(playerid, d_DMStats, DIALOG_STYLE_LIST, "Deathmatch Statistics", str, "Select", "Exit");
				}
		    }
	    }
	    else bitFalse(bPlayerGameSettings[playerid], checkingstats);
	}
	if(dialogid == d_GenStats)
	{
	    bitFalse(bPlayerGameSettings[playerid], checkingstats);
	}
	if(dialogid == d_DMStats)
	{
	    if(response&&listitem==7)ShowPlayerDialog(playerid, d_Awardlist, DIALOG_STYLE_LIST, "Awards - Obtained from doing certain actions in game, such as score chains or using certain weapons", GetAwardList(playerid), "Info", "Back");
	    else bitFalse(bPlayerGameSettings[playerid], checkingstats);
	}
	if(dialogid == d_Awardlist)
	{
	    if(response)
	    {
	        new str[128];
	        format(str, 128, "Awarded for killing %d players in a life with a %s", AwardData[listitem][awdReq], WepData[AwardData[listitem][wepid]][WepName]);
	        ShowPlayerDialog(playerid, d_Awardinfo, DIALOG_STYLE_MSGBOX, AwardData[listitem][awdName], str,	"Back", "Back");
	    }
	    else
		{
			new str[256];
			format(str, 256, "Kills\t\t\t\t%d\nDeaths\t\t\t\t%d\nXP\t\t\t\t%d\nRank\t\t\t\t%d (%s)\nNext Rank\t\t\t%d (%s)\nXP To Go\t\t\t%d\nAwards...",pKills(playerid),pDeaths(playerid),pExp(playerid),pRank(playerid),RankNames[pRank(playerid)],pRank(playerid)+1,RankNames[pRank(playerid)+1],(RequiredExp[pRank(playerid)+1]-pExp(playerid)));
			ShowPlayerDialog(playerid, d_DMStats, DIALOG_STYLE_LIST, "Deathmatch Statistics", str, "Select", "Exit");
		}
	}
	if(dialogid == d_Awardinfo)if(response||!response)ShowPlayerDialog(playerid, d_Awardlist, DIALOG_STYLE_LIST, "Awards - Obtained from doing certain actions in game, such as score chains or using certain weapons", GetAwardList(playerid), "Info", "Back");

	if(dialogid == d_Colourlist)
	{
  		if(response)
		{
		    new pFile[40];
			pFile=GetFile(playerid);
			SetPlayerColor(playerid, cArray[listitem][colour_hex]);
			pColour(playerid)=listitem;
			file_Open(pFile);
			file_SetVal("colour", listitem);
			file_Save(pFile);
			file_Close();
		}
	}
	if(dialogid == d_SpawnList)
	{
	    if(response)SetPlayerSpawnCam(playerid, listitem);
	    else
		{
		    new Float:x, Float:y, Float:z, Float:r;
		    GetPlayerPos(playerid, x, y, z);
		    GetPlayerFacingAngle(playerid, r);
			SetCameraBehindPlayer(playerid);
			SetSpawnInfo(playerid, NO_TEAM, GetPlayerSkin(playerid), x, y, z, r, 0,0,0,0,0,0);
			FirstTimeSpawn[playerid]=false;
		}
	}
	if(dialogid==d_Weather)GlobalWeather=strval(inputtext);
	if(dialogid==d_FreeDMList)ActivateFreeDM(listitem);
	if(dialogid==d_RadioList)
	{
	    if(response)PlayAudioStreamForPlayer(playerid, RadioStreams[listitem][0]);
	    else StopAudioStreamForPlayer(playerid);
	}
	return 1;
}
public OnRconCommand(cmd[])
{
	if(!strcmp(cmd,"pinfo"))
	{
		new n;
		PlayerLoop(i)
		{
			if(IsPlayerConnected(i))
			{
				if(n == 0)
				{
					print("ID: Name:			 IP:			   Ping: RCON: Vehicle:		  State:");
					print("--- -----			 ---			   ----- ----- --------		  ------");
					n++;
				}

				//--------------ID---------------//

				new Tab_PlayerID_Length[3];
				if(i >= 0 && i <= 9) { Tab_PlayerID_Length = "  "; }
				if(i >= 10 && i <= 99) { Tab_PlayerID_Length = " "; }
				if(i >= 100) { Tab_PlayerID_Length = ""; }

				//-------------Name--------------//

				new PlayerName[MAX_PLAYER_NAME];
				GetPlayerName(i, PlayerName, sizeof(PlayerName));

				//--------------IP---------------//

				new PlayerIp[16];
				GetPlayerIp(i, PlayerIp, sizeof(PlayerIp));

				//-------------Ping--------------//

				new PlayerPing = GetPlayerPing(i);
				new Tab_PlayerPing_Length[4];
				if(PlayerPing >= 0 && PlayerPing <= 9) { Tab_PlayerPing_Length = "   "; }
				if(PlayerPing >= 10 && PlayerPing <= 99) { Tab_PlayerPing_Length = "  "; }
				if(PlayerPing >= 100 && PlayerPing <= 999) { Tab_PlayerPing_Length = " "; }
				if(PlayerPing >= 1000) { Tab_PlayerPing_Length = " "; }

				//-------------RCON--------------//

				new PlayerAdmin[7];
				if(IsPlayerAdmin(i) == 1) { PlayerAdmin = "yes"; }
				if(IsPlayerAdmin(i) == 0) { PlayerAdmin = "no"; }

				//------------Vehicle------------//

				new PlayerVehicleModelID;
				if(IsPlayerInAnyVehicle(i) == 1)
				{
				 	PlayerVehicleModelID = GetVehicleModel(GetPlayerVehicleID(i));
				}
				else { PlayerVehicleModelID = 0; }

				//-------------State-------------//

				new PlayerState[10];
				if(GetPlayerState(i) == 1) { PlayerState = "On foot"; }
				if(GetPlayerState(i) == 2) { PlayerState = "Driver"; }
				if(GetPlayerState(i) == 3) { PlayerState = "Passenger"; }
				if(GetPlayerState(i) == 7) { PlayerState = "Dead"; }
				if(GetPlayerState(i) == 0 || GetPlayerState(i) == 4 ||
				GetPlayerState(i) == 5 || GetPlayerState(i) == 6 ||
				GetPlayerState(i) == 8) { PlayerState = "/"; }

				//------------Message------------//

				printf("%i%s %17s %17s %i %s %5s %17s %s", i, Tab_PlayerID_Length, PlayerName, PlayerIp, PlayerPing, Tab_PlayerPing_Length, PlayerAdmin, VehicleNames[PlayerVehicleModelID-400], PlayerState);
			}
		}
		if(n == 0) { print("There are no players on the server."); }
	}
	return 1;
}
enum teledata
{
	telecmd[50],
	teleinfo[50],
	Float:teleX,
	Float:teleY,
	Float:teleZ,
	Freeze
}
new TeleCMD[43][teledata]=
{
	//Places
	{"ls",			"Los Santos",				1186.8282,-1324.1444,13.5591,	0},
	{"sf",			"San Fierro",				-1986.2489,288.5100,34.2673,	0},
	{"lv",			"Las Venturas",				2032.2878,1342.8140,10.8203,	0},
	{"bay",			"Bayside",					-2461.9080,2210.1062,4.9844,	0},
	{"sd",			"Summer Drive",				2079.84204,2704.86962,10.78,	0},
	{"lsair",		"LS Airport", 				2056.7532,-2620.5632,13.5469,	0},
	{"sfair",		"SF Airport", 				-1225.1724,45.7877,14.1339,		0},
	{"lvair",		"LV Airport", 				1324.4420,1485.6570,10.8203,	0},
	{"aa",			"Abandonned Airstrip",		413.1822,2520.4240,19.1476,		0},
	{"airbase",		"Army Base",				291.6556,2035.5938,17.6406,		0},
	{"ch",			"Mount Chilliad",			-2315.4626,-1667.9355,482.9564,	0},
	{"qu",			"Hunter Quarry",			826.0663,850.5839,11.7055,		0},
	{"ear",			"The Big Ear",          	-292.0604,1535.9839,75.5625,	0},
	//Races
	{"race1",		"LV Circit race",			2086.2029,864.8795,6.8716,		0},
	{"race2",		"Coast Road race",			-189.9003,244.9968,12.2681,		0},
	{"race3",		"LS Circit race",			2172.3770,318.3593,33.1021,		0},
	{"rally1",		"Woodland Rally",			-567.8081,-188.6419,78.4063,	0},
	{"rally2",		"Riverside Rally",			1556.1964,33.4867,24.1641,		0},
	{"drag1",		"Bridge 1 drag race",		-2694.4155,1228.3242,55.5697,	0},
	{"drag2",		"Bridge 2 drag race",		-1121.5398,1119.5364,37.8678,	0},
	{"drag3",		"Tunnel drag race",			-891.5397,-1115.5581,98.9609,	0},
	//Drifts
	{"drift1",		"The Big Ear drift road",	-292.0604,1535.9839,75.5625,	0},
	{"drift2",		"Country Drift",			-2418.5100,-594.7469,132.7144,	0},
	{"drift3",		"Montgomery Hill",			-780.7125,-1735.8167,96.0833,	0},
	//Jumps
	{"bigjump1",	"LS stuntpark north jump",	1488.7493,2762.3332,716.8652,	1},
	{"bigjump2",	"LS stuntpark south jump",	1468.4252,166.1907,779.6299,	1},
	{"hugejump",	"The Huge Jump",			-1309.0759,3662.8618,4001.0,	1},
	{"halfhugejump","halfway down Huge Jump",	-1274.1927,1049.4258,1138.1747,	1},
	//Mod Shops
	{"waa",			"Wheel Arch Angels",		-2706.4019,239.1864,4.1797,		0},
	{"modlv",		"LV Transfender",			2395.5994,1036.2928,10.8203,	0},
	{"modsf",		"SF Transfender",			-1937.5045,227.4620,34.1563,	0},
	{"loco",		"Loco-Low-Co",				2643.8112,-2031.6405,13.3148,	0},
	//Random
	{"thing1",		"some random thing",		3231.5654, 296.7467, 10.3464,	0},
	{"thing2",		"another random thing",		-2886.1199,2555.3694,262.7934,	0},
	{"thing3",		"the third random thing",	-2824.2800,2174.8635,177.1884,	0},
	{"probe",		"Li'l Probe Inn",			-84.7142, 1372.0991, 10.2737,	0},
	{"farm",		"LS Farm",					-1110.9705,-1004.5992,133.2802,	0},
	{"bridge1",		"San Fierro Bridge 1",		-2680.0869,1595.0314,217.2739,	0},
	{"bridge2",		"San Fierro Bridge 2",		-1267.0668,965.4189,133.0514,	0},
	{"cliff1",		"North Face Cliff",			-2569.2708,2901.4063,96.6526,	0},
	{"cliff2",		"North Face Cliff",			-2029.9653,2967.0586,57.1802,	0},
	{"cliff3",		"North Face Cliff",			-1773.7783,2930.8472,56.5827,	0},
	{"cliff4",		"North Face Cliff",			-1504.2698,2974.6489,42.4324,	0}
};

public OnPlayerCommandText(playerid, cmdtext[])
{
	new
		cmd[30],
		params[98],
		szFuncName[64];
	sscanf(cmdtext, "s[30]s[98]", cmd, params);

	if(strcmp(cmdtext, "/pm", false, 3))printf("[cmd] %s entered command: %s", GetName(playerid), cmdtext);

	if(script_PrivCars_Command(playerid, cmd))return 1;


	for(new c;c<sizeof(TeleCMD);c++)
	{
		if(!strcmp(cmd[1], TeleCMD[c][telecmd], true))
		{
		    TelePlayer(playerid, TeleCMD[c][teleX], TeleCMD[c][teleY], TeleCMD[c][teleZ]);
		    if(TeleCMD[c][Freeze])TogCon(playerid, 3000);
		    msgaF(LGREEN, "%s Has gone to %s: /%s", GetName(playerid), TeleCMD[c][teleinfo], TeleCMD[c][telecmd]);
		    return 1;
		}
	}
	if(4>=pAdmin(playerid)>0 && !IsPlayerAdmin(playerid))
	{
		new tmpCmdID;
		while(tmpCmdID<MAX_ADMIN_CMD)
		{
			if(!strcmp(cmd[1], AdminCommands[tmpCmdID++][szCommand], true))
			{
				if(pAdmin(playerid)<AdminCommands[tmpCmdID][iCmdLevel])return msg(playerid, RED, "You have insufficient admin rights to use that command");
				break;
			}
		}
	}
	format(szFuncName, 64, "cmd_%s", cmd[1]);
	if(funcidx(szFuncName)==-1)
	{
		if(IsPlayerAdmin(playerid) && pAdmin(playerid)>3)format(szFuncName, 64, "acmd_%s", cmd[1]);
		if(funcidx(szFuncName)==-1)return msg(playerid, ORANGE, "** that is not a recognized command, check the /help, /cmds and /teles");
	}
	if(isnull(params))return CallLocalFunction(szFuncName, "is", playerid, "\1");
	else return CallLocalFunction(szFuncName, "is", playerid, params);
}


CMD:skin(playerid, params[])
{
	new skinid;
	if(sscanf(params, "d", skinid)) msg(playerid, YELLOW, "Usage: /skin [skinid]");
	else if(!IsValidSkin(skinid)) return msg(playerid, RED, "Use A Number Above 0 And Below 287");
	else
	{
		SetPlayerSkin(playerid, skinid);
		msg(playerid, YELLOW, "**Skin Changed!");
	}
	return 1;
}
CMD:sp(playerid, params[])
{
	new posN[128];
	if(!sscanf(params, "s[128]", posN))
	{
		new string[128], Float:x, Float:y, Float:z, Float:r, pCar = GetPlayerVehicleID(playerid);
		if(IsPlayerInAnyVehicle(playerid))
		{
			GetVehiclePos(pCar, x, y, z);
			GetVehicleZAngle(pCar, r);
		}
		else
		{
			GetPlayerPos(playerid, x, y, z);
			GetPlayerFacingAngle(playerid, r);
		}
		format(string, 128, "%02f, %02f, %02f, %02f", x, y, z, r);
		file_Open("savedpositions.txt");
		file_SetStr(posN, string);
		file_Save("savedpositions.txt");
		file_Close();
		msgF(playerid, GOLD, "%s = %s Saved!", posN, string);
	}
	else msg(playerid, GREY, "Usage: /sp [position name]");
 	return 1;
}
CMD:tp(playerid, params[])
{
	new posN[128];
	if(!sscanf(params, "s[128]", posN))
	{
		new Float:x, Float:y, Float:z, Float:r, pCar = GetPlayerVehicleID(playerid);
		file_Open("savedpositions.txt");
		sscanf(file_GetStr(posN), "p<,>ffff", x, y, z, r);
		file_Close();
		msgF(playerid, GOLD, "%s = %s Loaded!", posN, file_GetStr(posN));
		if(IsPlayerInAnyVehicle(playerid))
		{
			SetVehiclePos(pCar, x, y, z);
			SetVehicleZAngle(pCar, r);
		}
		else
		{
			SetPlayerPos(playerid, x, y, z);
			SetPlayerFacingAngle(playerid, r);
		}
	}
	else msg(playerid, GREY, "Usage: /tp [position name]");
 	return 1;
}
CMD:pm(playerid, params[])
{
	new id, msg[98];
	if(sscanf(params, "ds[98]", id, msg))msg(playerid, YELLOW, "Usage: /pm [playerid] [message]");
	else if(!IsPlayerConnected(id))msg(playerid, RED, "Invalid ID");
	else
	{
	    if(Blocked[playerid][id])msg(playerid, RED, "This player has blocked you from sending persona messages and using private chat");
	    else
	    {
			msgF(id, ORANGE, "PM From %s[%d]: %s", GetName(playerid), playerid, msg);
			msgF(playerid, ORANGE, "PM To %s[%d]: %s", GetName(id), id, msg);
			GameTextForPlayer(id, "~n~~n~~n~~n~~n~~b~PM RECIEVED", 1000, 5);

			new logfile[30], line[256], y, m, d, h, mn, s, File:f;
			getdate(y, m, d);
			gettime(h, mn, s);
			format(logfile, 30, "Server/Logs/%d-%d-%d.txt", d, m, y);
			format(line, 256, "%d:%d:%d-%s>%s=%s", h, mn, s, GetName(playerid), GetName(id), msg);
			if(!fexist(logfile))file_Create(logfile);
			f=fopen(logfile, io_append);
			fwrite(f, line);
			fclose(f);
		}
	}
	return 1;
}
CMD:chat(playerid, params[])
{
	new id=strval(params);
	if(!IsPlayerConnected(id)||!IsNumeric(params)||!(strlen(params)>0))msg(playerid, YELLOW, "Usage: /chat [playerid] - your chat messages will only be sent to this player");
	else
	{
	    if(Blocked[playerid][id])msg(playerid, RED, "This player has blocked you from sending personal messages and using private chat");
	    else
	    {
	    	if(Chatting[playerid]==-1)
	    	{
	    		Chatting[playerid]=id;
	    		Chatting[id]=playerid;
	    		msgF(playerid, BLUE, "You are now in private chat with %s", GetName(id));
	    		msgF(id, BLUE, "You are now in private chat with %s", GetName(playerid));
	    	}
	    	else
	    	{
	    	    Chatting[playerid]=-1;
	    	    Chatting[id]=-1;
	    		msgF(playerid, BLUE, "You have ended chat with %s", GetName(id));
	    		msgF(id, BLUE, "%s has ended the chat with you", GetName(playerid));
	    	}
	    }
	}
	return 1;
}
CMD:block(playerid, params[])
{
	new id=strval(params);
	if(!IsPlayerConnected(id)||!IsNumeric(params)||!(strlen(params)>0))msg(playerid, YELLOW, "Usage: /block [playerid] - Block or Unblock a player from PM and Private Chatting with you");
	else
	{
	    if(Blocked[playerid][id])
	    {
			Blocked[playerid][id]=false;
			msg(playerid, YELLOW, "%s has been unblocked, they can now send you personal messages and chat with you");
	    }
	    else
	    {
			Blocked[playerid][id]=true;
			msg(playerid, YELLOW, "%s has been blocked from sending you personal messages and chatting with you. You can also /report them to an admin");
	    	if(Chatting[playerid]==id)
	    	{
	    	    Chatting[playerid]=-1;
	    	    Chatting[id]=-1;
	    		msgF(playerid, BLUE, "You have ended chat with %s", GetName(id));
	    		msgF(id, BLUE, "%s has ended the chat with you", GetName(playerid));
	    	}
		}
	}
	return 1;
}
CMD:hide(playerid, params[])
{
	new id=strval(params);
	if(!IsPlayerConnected(id)||!IsNumeric(params)||!(strlen(params)>0))msg(playerid, YELLOW, "Usage: /hide [playerid] - Hide a players chat text from appearing on your chat box");
	else
	{
	    if(Hidden[playerid][id])
	    {
			Hidden[playerid][id]=false;
			msg(playerid, YELLOW, "%s has been unhidden, you can now see their chat text");
	    }
	    else
	    {
			Hidden[playerid][id]=true;
			msg(playerid, YELLOW, "%s has been hidden, you won't see their chat text anymore. You can also /report them to an admin");
		}
	}
	return 1;
}
CMD:g(playerid, params[])
{
	if(strlen(params)>0)OnPlayerText(playerid, params);
	else msg(playerid, YELLOW, "Usage: /g [message]");
	return 1;
}
CMD:t(playerid, params[])
{
	new t[128];
	if(sscanf(params, "s[128]", t))return msg(playerid, RED, "Usage: /t [message] - Send a message to all players in your team");
	else TeamMsgF(pTeam(playerid), WHITE, ""#C_YELLOW"[T]"#C_BLUE"%s: "#C_WHITE"%s", GetName(playerid), t);
	return 1;
}
CMD:me(playerid, params[])
{
	if(!params[0])return msg(playerid,YELLOW,"Usage: /me [Message]");
	else
	{
		Phonetic(params);
		PlayerInsert(params);
		msgaF(GREY, "* %s %s", GetName(playerid), params);
	}
	return 1;
}
CMD:ct(playerid, params[])
{
	new msg[128];
	if(!sscanf(params, "s[128]", msg))
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			new pcar = GetPlayerVehicleID(playerid);
			PlayerLoop(i)
			{
				if(IsPlayerInVehicle(i, pcar))
				{
					Phonetic(msg);
					PlayerInsert(msg);
					msgF(i, GREEN, "CarTalk-%s: %s", GetName(playerid), msg);
				}
			}
		}
		else msg(playerid, RED, "You are not in a car you plonker");
	}
	else msg(playerid, YELLOW, "Usage: /ct [message] - Sends a message to all players in your car");
	return 1;
}
CMD:setfreq(playerid, params[])
{
	new frq;
	if(!sscanf(params, "d", frq))
	{
		Freq[playerid] = frq;
		msgF(playerid, ORANGE, "Your frequency has been changed to %d", frq);
	}
	else msg(playerid, YELLOW, "Usage: /setfreq [frequency]");
	return 1;
}
CMD:r(playerid, params[])
{
	new msg[128];
	if(!sscanf(params, "s[128]", msg))
	{
		PlayerLoop(i)
		{
			if(Freq[i] == Freq[playerid])
			{
				msgF(i, BROWN, "[c%d]%s: %s", Freq[playerid], GetName(playerid), msg);
			}
		}
	}
	else msg(playerid, YELLOW, "Usage: /radio [message]"); // player didnt type anything
	return 1;
}
CMD:steve(playerid, params[])
{
	if(PlayerNameIs(playerid, "[HLF]Southclaw")&&IsPlayerAdmin(playerid))
	{
		if(stremt(params))return msg(playerid, YELLOW, "Usage: /steve [phrase]");
		else
		{
		    gSteveTempStr[0]='\0';
		    strcat(gSteveTempStr, params);
			SteveTalk();
		}
	}
	else return 0;
	return 1;
}
CMD:idea(playerid, params[])
{
	new idea[128];
	if(sscanf(params, "s[128]", idea)) return msg(playerid, YELLOW, "Usage: /idea [idea]");
	else
	{
		new info[32], y, m, d;
		getdate(y, m, d);
		format(info, 32, "%s-%d%/d/%d", GetName(playerid), y, m, d);
		file_Open("ideas.txt");
		file_SetStr(info, idea);
		file_Save("ideas.txt");
		file_Close();
	}
	return 1;
}
CMD:bug(playerid, params[])
{
	new bug[128];
	if(sscanf(params, "s[128]", bug)) return msg(playerid, YELLOW, "Usage: /bug [bug]");
	else
	{
		new info[32], y, m, d;
		getdate(y, m, d);
		format(info, 32, "%s-%d%/d/%d", GetName(playerid), y, m, d);
		file_Open("bugs.txt");
		file_SetStr(info, bug);
		file_Save("bugs.txt");
		file_Close();
	}
	return 1;
}
CMD:clock(playerid, params[])
{
	new s[128],
		Hour,
		Minutes,
		Seconds;
	gettime(Hour,Minutes,Seconds);
	format(s,sizeof(s),"~b~Time:~w~ %d : %d %d",Hour,Minutes,Seconds);
	return GameTextForPlayer(playerid,s,4000,3);
}
CMD:date(playerid, params[])
{
	new s[128],
		Year,
		Month,
		Day;
	getdate(Year,Month,Day);
	format(s,sizeof(s),"~b~Date:~w~ %d . %d %d",Day,Month,Year);
	return GameTextForPlayer(playerid,s,4000,3);
}
CMD:pos(playerid, params[])
{
	new
		Float:fX,
		Float:fY,
		Float:fZ;
	GetPlayerPos(playerid,fX,fY,fZ);
	msgF(playerid,YELLOW,"Position: %f, %f, %f",fX,fY,fZ);
	return 1;
}
CMD:report(playerid, params[])
{
	new id, msg[128];
	if(sscanf(params, "ds[128]", id, msg)) return msg(playerid,YELLOW,"Usage: /report [playerid] [Reason]");
	else if(!IsPlayerConnected(id)) return msg(playerid,RED,"Invalid ID");
	else msgAdminsF("%s Has reported %s for %s", GetName(playerid), GetName(id), msg);
	return 1;
}
CMD:givecash(playerid, params[])
{
	new id, amount;
	if(sscanf(params, "dd", id, amount)) msg(playerid, YELLOW, "Usage  /givecash [playerid] [amount]");
	else if(!IsPlayerConnected(id)) msg(playerid, RED, "Invalid ID");
	else if(amount > GetPlayerMoney(playerid)) msg(playerid, RED, "**You Don't Have That Much Money!");
	else if(amount < 1) return msg(playerid, RED, "**You can't take money away from players!");
	else
	{
		GivePlayerMoney(id, amount);
		GivePlayerMoney(playerid, -amount);

		msgF(playerid, YELLOW, "**You've Given $%d To %s.", amount, GetName(id));
		msgF(id, YELLOW,  "**You've Recieved $%d From %s.", amount, GetName(playerid));
	}
	return 1;
}
CMD:carcolour(playerid, params[])
{
	if(IsPlayerInAnyVehicle(playerid))
	{
		new c1, c2, pCar = GetPlayerVehicleID(playerid);
		if(!sscanf(params, "dD(1)", c1, c2))
		{
			ChangeVehicleColor(pCar, c1, c2);
	    	for(new h; h<MAX_HOUSE; h++)
	    	{
	    	    for(new c;c<HouseData[h][h_MaxCarCount];c++)
	    	    {
					if(pCar==HouseData[h][h_CarID][c])
					{
						HouseData[h][h_CarC1]=c1,
						HouseData[h][h_CarC2]=c2;
					    SaveHouseCar(h, c, pCar, HouseData[h][h_CarC1], HouseData[h][h_CarC2]);
					}
				}
			}
		}
		else msg(playerid, YELLOW, "Usage: /carcolor [colour 1] [optional:colour 2]");
	}
	return 1;
}
CMD:para(playerid, params[])
{
	GivePlayerWeapon(playerid, Parachute, 1);
	return 1;
}
CMD:getstats(playerid, params[])
{
	if(strlen(params))
	{
		new
			id,
			name[24],

			stat_admin,
			stat_rank,
			stat_kills,
			stat_deaths,
			stat_xp,
			stat_cash,
			stat_ip[16],
			stat_password[50],

			t_total,
			t_session,
			t_inveh,
			t_onfoot,

			str[1024],
			g_str[128],
			inveh_additional,
			onfoot_additional,
			hstr[40];

		if(!sscanf(params, "d", id))
		{
			if(!IsPlayerConnected(id))return msg(playerid, RED, "Invalid ID");
			format(name, 24, GetName(id));

			format(stat_password, 50, pInfo[id][pI_Password]);
			stat_admin		=pAdmin(id);
			stat_rank       =pRank(id);
			stat_kills      =pKills(id);
			stat_deaths     =pDeaths(id);
			stat_xp         =pExp(id);
			stat_cash		=GetPlayerMoney(id);
			format(stat_ip, 16, pInfo[id][pI_IP]);

			if(EnterVehTick[playerid]==0)inveh_additional=0;
			else inveh_additional=(GetTickCount()-EnterVehTick[playerid]);
			if(EnterFootTick[playerid]==0)onfoot_additional=0;
			else onfoot_additional=(GetTickCount()-EnterFootTick[playerid]);
			t_total=(pInfo[playerid][pI_TimePlayed]+(GetTickCount()-pInfo[playerid][pI_JoinTick])),
			t_session=(GetTickCount()-pInfo[playerid][pI_JoinTick]),
			t_inveh=(pInfo[playerid][pI_TimeInVeh]+inveh_additional),
			t_onfoot=(pInfo[playerid][pI_TimeOnFoot]+onfoot_additional);
		}
		else if(!sscanf(params, "s[24]", name))
		{
			id=GetPlayerID(name);
			if(IsPlayerConnected(id))
			{
				format(stat_password, 50, pInfo[id][pI_Password]);
				stat_admin		=pAdmin(id);
				stat_rank       =pRank(id);
				stat_kills      =pKills(id);
				stat_deaths     =pDeaths(id);
				stat_xp         =pExp(id);
				stat_cash		=GetPlayerMoney(id);
				format(stat_ip, 16, pInfo[id][pI_IP]);

				if(EnterVehTick[playerid]==0)inveh_additional=0;
				else inveh_additional=(GetTickCount()-EnterVehTick[playerid]);
				if(EnterFootTick[playerid]==0)onfoot_additional=0;
				else onfoot_additional=(GetTickCount()-EnterFootTick[playerid]);
				t_total=		(pInfo[playerid][pI_TimePlayed]+(GetTickCount()-pInfo[playerid][pI_JoinTick])),
				t_session=		(GetTickCount()-pInfo[playerid][pI_JoinTick]),
				t_inveh=		(pInfo[playerid][pI_TimeInVeh]+inveh_additional),
				t_onfoot=		(pInfo[playerid][pI_TimeOnFoot]+onfoot_additional);
			}
			else
			{
			    new file[50];
			    format(file, 50, userfile, name);
			    if(fexist(file))
			    {
			        file_Open(file);
					format(stat_password, 50, file_GetStr("password"));
					stat_admin		=file_GetVal("admin");
					stat_rank       =file_GetVal("rank");
					stat_kills      =file_GetVal("kills");
					stat_deaths     =file_GetVal("deaths");
					stat_xp         =file_GetVal("xp");
					stat_cash		=file_GetVal("cash");
					format(stat_ip, 16, file_GetStr("ip"));

					t_total			=file_GetVal("timeplayed");
					t_session		=0;
					t_inveh			=file_GetVal("timeinveh");
					t_onfoot		=file_GetVal("timeonfoot");
					file_Close();
			    }
			    else return msg(playerid, RED, "User does not exist");
			}
		}

		format(hstr, 40, "Profile For: {YELLOW}%s", name);
		strcat(str, FormatColours("{WHITE}-  General\n"));
		format(g_str, 128, "{BLUE}Admin Level:\t\t\t{GREEN}%d\n", stat_admin);
		strcat(str, FormatColours(g_str));
		if(IsPlayerConnected(id))format(g_str, 128, "{BLUE}Time Played (This Session):\t{GREEN}%s\n", TimeStamp(t_session));
		else format(g_str, 128, "{GREY}Time Played (This Session):\t(n/a)\n", TimeStamp(t_session));
		strcat(str, FormatColours(g_str));
		format(g_str, 128, "{BLUE}Time Played (All Time):\t{GREEN}%s\n", TimeStamp(t_total));
		strcat(str, FormatColours(g_str));
		format(g_str, 128, "{BLUE}Time In Vehicle:\t\t{GREEN}%s\n",TimeStamp(t_inveh));
		strcat(str, FormatColours(g_str));
		format(g_str, 128, "{BLUE}Time On Foot:\t\t\t{GREEN}%s\n", TimeStamp(t_onfoot));
		strcat(str, FormatColours(g_str));

		strcat(str, FormatColours("\n\n{WHITE}-  Deathmatch\n"));
		format(g_str, 128, "{BLUE}Rank:\t\t\t\t{GREEN}%s(%d)\n", RankNames[stat_rank], stat_rank);
		strcat(str, FormatColours(g_str));
		format(g_str, 128, "{BLUE}Kills:\t\t\t\t{GREEN}%d\n", stat_kills);
		strcat(str, FormatColours(g_str));
		format(g_str, 128, "{BLUE}Deaths:\t\t\t{GREEN}%d\n", stat_deaths);
		strcat(str, FormatColours(g_str));
		format(g_str, 128, "{BLUE}XP:\t\t\t\t{GREEN}%d\n", stat_xp);
		strcat(str, FormatColours(g_str));
		format(g_str, 128, "{BLUE}Next Rank:\t\t\t{GREEN}%s(%d)\n", RankNames[stat_rank+1], (stat_rank+1));
		strcat(str, FormatColours(g_str));
		format(g_str, 128, "{BLUE}XP To Go:\t\t\t{GREEN}%d", (RequiredExp[stat_rank+1]-pExp(playerid)));
		strcat(str, FormatColours(g_str));

		if(pAdmin(playerid) >= 1)
		{
		    new
		        c=IsPlayerConnected(id),
				Float:stat_hp,
				Float:stat_ap,
				InVeh[30];
			if(c)
			{
				GetPlayerHealth(id, stat_hp);
				GetPlayerArmour(id, stat_ap);
				if(IsPlayerInAnyVehicle(id))InVeh=VehicleNames[GetVehicleModel(GetPlayerVehicleID(id))-400];
				else InVeh="No";
			}

			if(pAdmin(playerid)<4)format(stat_password, 50, "[Private]");

			format(g_str, 128, "\n\n{YELLOW}-  Additional Information:\n\n");
			strcat(str, FormatColours(g_str));
			if(c)format(g_str, 128, "{BLUE}Health:\t\t\t{GREEN}%.2f\n", stat_hp);
			else format(g_str, 128, "{GREY}Health:\t\t\t(n/a)\n");
			strcat(str, FormatColours(g_str));
			if(c)format(g_str, 128, "{BLUE}Armour:\t\t{GREEN}%.2f\n", stat_ap);
			else format(g_str, 128, "{GREY}Armour:\t\t(n/a)\n");
			strcat(str, FormatColours(g_str));
			format(g_str, 128, "{BLUE}IP:\t\t\t{GREEN}%s\n", stat_ip);
			strcat(str, FormatColours(g_str));
			format(g_str, 128, "{BLUE}Password:\t\t{GREEN}%s\n", stat_password);
			strcat(str, FormatColours(g_str));
			if(c)format(g_str, 128, "{BLUE}Using Godmode:\t{GREEN}%s\n", BoolToString((bPlayerGameSettings[playerid]&GodMode), 1));
			else format(g_str, 128, "{GREY}Using Godmode:\t(n/a)\n");
			strcat(str, FormatColours(g_str));
			format(g_str, 128, "{BLUE}Money:\t\t{GREEN}%d\n", stat_cash);
			strcat(str, FormatColours(g_str));
			if(c)format(g_str, 128, "{BLUE}In Vehicle:\t\t{GREEN}%s\n", InVeh);
			else format(g_str, 128, "{GREY}In Vehicle:\t\t(n/a)\n");
			strcat(str, FormatColours(g_str));
			format(g_str, 128, "{BLUE}Country:\t\t{GREEN}%s", GetIpCountry(stat_ip));
			strcat(str, FormatColours(g_str));
		}
		ShowPlayerDialog(playerid, d_Cmds, DIALOG_STYLE_MSGBOX, FormatColours(hstr), str, "Close", "");
	}
	else return msg(playerid, YELLOW, "Usage: /getstats [playerid/playername] You can also check the stats of a player even if they aren't on the server");
	return 1;
}
CMD:qmsg(playerid, params[])
{
	new id, msg[128];
	if(sscanf(params, "ds[128]", id, msg))return msg(playerid, YELLOW, "Usage: /qmsg [message number 0-9] [message - character limit: 50]");
	else
	{
		pChat[playerid][id][0]='\0';
		strcat(pChat[playerid][id], msg);
		msgF(playerid, YELLOW, "QuickChat phrase %d saved, use by typing '#%d' in chat for a list of Quickchat Phrases type '/qlist'", id, id);
	}
	return 1;
}



//================================================================Debug Commands


new
	Text:dMarker[2],
	dObject,
	Float:g_dX,
	Float:g_dY,
	Float:g_dZ,
	
	Float:g_OriginX,
	Float:g_OriginY,
	
	Float:g_tmpZ;

CMD:dirmark(playerid, params[])
{
	GetPlayerPos(playerid, g_dX, g_dY, g_dZ);

	CreateDynamicObject(1318, g_dX, g_dY, g_dZ, 90.0, 0.0, 0.0);
	dObject=CreateDynamicObject(1318, g_dX+1.0, g_dY, g_dZ, 0.0, 0.0, 0.0);

	SetTimerEx("DirMarkTimer", 100, true, "d", playerid);

	g_OriginX=320.0;
	g_OriginY=240.0;

	CreateDot(playerid, 1, g_OriginX, g_OriginY);

	return 1;
}
CMD:setorigin(playerid, params[])
{
	new
	    Float:x,
	    Float:y;
	sscanf(params, "ff", x, y);
	
	g_OriginX=x;
	g_OriginY=y;
	
	CreateDot(playerid, 1, g_OriginX, g_OriginY);

	return 1;
}
forward DirMarkTimer(playerid);
public DirMarkTimer(playerid)
{
	new
		Float:posX,
		Float:posY,
		Float:Angle;

	GetPlayerPos(playerid, posX, posY, g_tmpZ);
	Angle = atan2((posY - g_dY), (posX - g_dX)) + 270.0,
	//             DEST   POINT   DEST   POINT

	posX = g_dX + (1.0 * floatsin(-Angle, degrees));
	posY = g_dY + (1.0 * floatcos(-Angle, degrees));
	
	SetDynamicObjectPos(dObject, posX, posY, g_dZ);

	posX = g_OriginX + (30.0 * floatsin(-Angle+180.0, degrees));
	posY = g_OriginY + (30.0 * floatcos(-Angle+180.0, degrees));

	CreateDot(playerid, 0, posX, posY);
}
/*
Float:GetAngleToPoint(Float:fPointX, Float:fPointY, Float:fDestX, Float:fDestY)
	return atan2((fDestY - fPointY), (fDestX - fPointX)) + 270.0;
*/
CreateDot(playerid, index, Float:x, Float:y)
{
	TextDrawDestroy			(dMarker[index]);
	dMarker[index]			=TextDrawCreate(x, y, ".");
	TextDrawBackgroundColor	(dMarker[index], 255);
	TextDrawFont			(dMarker[index], 1);
	TextDrawLetterSize		(dMarker[index], 1.000000, 4.000000);
	TextDrawColor			(dMarker[index], -16776961);
	TextDrawSetOutline		(dMarker[index], 0);
	TextDrawSetProportional	(dMarker[index], 1);
	TextDrawAlignment		(dMarker[index], 1);
	TextDrawSetShadow		(dMarker[index], 0);
	TextDrawShowForPlayer	(playerid, dMarker[index]);
}

CMD:getdata(playerid, params[])
{
	new id;
	if (sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /getdata [playerid]");
	else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
	else msgF(playerid, ORANGE, "Team: %d - indm: %b - InLobby: %b - Interior: %d - VW: %d - State: %d - ReadyForDM: %d", pDM_Data[id][Team], bPlayerGameSettings[id]&InDM, bPlayerGameSettings[id]&InLobby, GetPlayerInterior(id), GetPlayerVirtualWorld(id), GetPlayerState(id), bPlayerGameSettings[id]&ReadyForDM);
	return 1;
}
CMD:loadmap(playerid, params[])
{
	new map;
	if(!sscanf(params, "d", map))LoadDM_Map(map);
	else return 0;
	return 1;
}
CMD:telemap(playerid, params[])
{
	new map;
	if(!sscanf(params, "d", map))
	{
	    new Float:spawnX, Float:spawnY, Float:spawnZ, fname[64], lineData[256];

		format(fname, 64, dmDataFile, map, MapNames[map]);
		file_Open(fname);
		format(lineData, 256, file_GetStr("GEN_spawn1"));
		sscanf(lineData, "p<,>fff", spawnX, spawnY, spawnZ);

		SetPlayerPos(playerid, spawnX, spawnY, spawnZ);
		SetPlayerVirtualWorld(playerid, DEATHMATCH_WORLD);
	}
	else return 0;
	return 1;
}
CMD:createmine(playerid,params[])
{
	new Float:p[3], str[40];
	GetPlayerPos(playerid, p[0], p[1], p[2]);
	format(str, 40, "(%f, %f, %f);", p[0], p[1], p[2]-1.0);
	file_Open("savedpositions.txt");
	file_SetStr(str, " // ");
	file_Save("savedpositions.txt");
	file_Close();
	return 1;
}
CMD:mjlob(playerid,params[])
{
	new r;
	if(!sscanf(params,"d",r))OnPlayerCommandText(r, "/joindm");
	return 1;
}
CMD:mjred(playerid,params[])
{
	new p;
	if(!sscanf(params,"d",p))
	{
		if(bServerGlobalSettings&DMInProgress)
		{
			if(bServerGlobalSettings&DMstarted)JoinQueue(p);
			else
			{
				HideMenuForPlayer(LobbyMenu, p);
				bitTrue(bPlayerGameSettings[p], ReadyForDM);
				FormatLobbyInfo(p);
				new r;
				PlayerLoop(i)if(bPlayerGameSettings[i]&ReadyForDM)r++;
				if( (r==GetPlayersInLobby()) && (GetPlayersInLobby()>=DMminP) )
				{
					LobbyCountInt=10;
					bitTrue(bServerGlobalSettings, LobbyCountingDown);
				}
			}
		}
		else HideMenuForPlayer(LobbyMenu, p);
	}
	return 1;
}
CMD:mjdm(playerid,params[])
{
	new r;
	if(!sscanf(params,"d",r))
	{
		bitTrue(bPlayerGameSettings[playerid], InDM);
		bitFalse(bPlayerGameSettings[playerid], InLobby);
		SetPlayerToTeam(r, 1);
	}
	return 1;
}
CMD:cob(playerid,params[])
{
	new o;
	if(!sscanf(params,"d",o))
	{
	    new Float:x, Float:y, Float:z;
	    GetPlayerPos(playerid, x, y, z);
	    CreateObject(o, x, y, z, 0, 0, 0);
	}
	return 1;
}
CMD:campos(playerid,params[])
{
	new Float:x, Float:y, Float:z;
	GetPlayerCameraPos(playerid, x, y, z);
	new str[40];
	format(str, 40, "(%f, %f, %f);", x, y, z);
	file_Open("savedpositions.txt");
	file_SetStr(str, " // ");
	file_Save("savedpositions.txt");
	file_Close();
	return 1;
}
CMD:changevw(playerid, params[])
{
	SetPlayerVirtualWorld(playerid, strval(params));
	return 1;
}
CMD:savepcar(playerid, params[])
{
	new n[24], c_1, c_2;
	if(sscanf(params, "s[24]dd", n, c_1, c_2))return msg(playerid, YELLOW, "Usage: /savepcar [playername] [colour1] [colour2]");
	else
	{
		new str[100],
		m=GetVehicleModel(GetPlayerVehicleID(playerid));
		format(str, 100, "{\"/cmd\",\t\"%s\",\t%d,\t%d,\t%d}", n, m, c_1, c_2);
		file_Open("savedpositions.txt");
		file_SetStr(n, str);
		file_Save("savedpositions.txt");
		file_Close();
	    msg(playerid, YELLOW, "Vehicle Saved");
	}
	return 1;
}
CMD:up(playerid, params[])
{
	new Float:d=float(strval(params)), Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	SetPlayerPos(playerid, x, y, z+d);
	return 1;
}
CMD:down(playerid, params[])
{
	new Float:d=float(strval(params)), Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	SetPlayerPos(playerid, x, y, z-d);
	return 1;
}
CMD:ford(playerid, params[])
{
	new Float:d=float(strval(params)), Float:x, Float:y, Float:z, Float:a;
	GetPlayerPos(playerid, x, y, z);
	GetPlayerFacingAngle(playerid, a);
	GetXYFromAngle(x, y, a, d);
	SetPlayerPos(playerid, x, y, z);
	return 1;
}
CMD:objtest(playerid, params[])
{
	new objtype, objid, hold, bone;
	if(sscanf(params, "dddd", objtype, objid, hold, bone))
	{
		msg(playerid, YELLOW, "Usage: /objtest [objtype], [objid], [hold 0/1], [bone <if:'hold'=1>]");
		msg(playerid, BLUE, " - objtypes: 0=Holding, 1=Lights, 2=Spraytags, 3=ParticleFX, 4=Misc, 5=DriveSections, 6=Stunting, 7=Clothing");
	}
	else
	{
	    new model, mName[20];
	    if(objtype==0)model = objects_Holding[objid][ob_id],		format(mName, 20, objects_Holding[objid][ob_name]);
	    if(objtype==1)model = objects_Lights[objid][ob_id],			format(mName, 20, objects_Lights[objid][ob_name]);
	    if(objtype==2)model = objects_Spraytags[objid][ob_id],		format(mName, 20, objects_Spraytags[objid][ob_name]);
	    if(objtype==3)model = objects_ParticleFX[objid][ob_id],		format(mName, 20, objects_ParticleFX[objid][ob_name]);
	    if(objtype==4)model = objects_Misc[objid][ob_id],			format(mName, 20, objects_Misc[objid][ob_name]);
	    if(objtype==5)model = objects_DriveSections[objid][ob_id],	format(mName, 20, objects_DriveSections[objid][ob_name]);
	    if(objtype==6)model = objects_Stunting[objid][ob_id],		format(mName, 20, objects_Stunting[objid][ob_name]);
	    if(objtype==7)model = objects_Clothing[objid][ob_id],		format(mName, 20, objects_Clothing[objid][ob_name]);

	    if(hold==1)
	    {
			if(objtype!=5||objtype!=6)SetPlayerAttachedObject(playerid, MISC_SLOT_1, model, bone);
		}
	    else
	    {
	        new Float:x, Float:y, Float:z;
	        GetPlayerPos(playerid, x, y, z);
	        GetXYInFrontOfPlayer(playerid, x, y, 10);
	        CreateObject(model, x, y, z, 0, 0, 0);
	    }
	    msgF(playerid, YELLOW, "Object Created: %s (%d)", mName, model);
	}
	return 1;
}
new Float:t1pos[3], Float:t2pos[3];
CMD:markspawn(playerid, params[])
{
	new Float:p[3];
	GetPlayerPos(playerid, p[0], p[1], p[2]);
	if(params[0] == 'r')
	{
	    for(new i=0;i<3;i++)t1pos[i] = p[i];
	    msg(playerid, YELLOW, "Raven Team Spawn Saved");
	}
	if(params[0] == 'v')
	{
	    for(new i=0;i<3;i++)t2pos[i] = p[i];
	    msg(playerid, YELLOW, "Valor Team Spawn Saved");
	}
	return 1;
}
CMD:savedmpos(playerid, params[])
{
	new DMn[50];
	if(sscanf(params, "s[50]", DMn))msg(playerid, YELLOW, "Usage: /savedmpos [DM name]");
	else
	{
	    new s[54];
	    format(s, 54, "%s.txt", DMn);
		if(!fexist(s))file_Create(s);
		new dmData[256];
		format(dmData, 256, "\n\tnew Float:%sSpawns[2][1][3]=\n\t{\n\t\t{\n\t\t\t{%f, %f, %f}\n\t\t},\n\t\t{\n\t\t\t{%f, %f, %f}\n\t\t}\n\t};", DMn, t1pos[0], t1pos[1], t1pos[2], t2pos[0], t2pos[1], t2pos[2]);
		file_Open(DMn);
		file_SetStr(DMn, dmData);
		file_Save(DMn);
		file_Close();
	}
	return 1;
}

CMD:reg(playerid, params[])
{
	new pFile[40];
	pFile=GetFile(playerid);
	if(!fexist(pFile))
	{
		new pwdstr[50];
		if(sscanf(params, "s[50]", pwdstr))ShowPlayerDialog(playerid, d_Register, DIALOG_STYLE_PASSWORD, "Register For A New Account", "Type your password below", "Accept", "Quit");
		else
		{
			CreateNewUserfile(playerid, pwdstr);
			Login(playerid);
		}
	}
	else
	{
		if(bPlayerGameSettings[playerid]&LoggedIn)msg(playerid, YELLOW, "**You Are already registered and logged in");
		else msg(playerid, YELLOW, "**You Are already registered, but not logged in, type /log");
	}
	return 1;
}
CMD:log(playerid, params[])
{
	new pFile[40];
	pFile=GetFile(playerid);
	if(fexist(pFile))
	{
		if(bPlayerGameSettings[playerid]&LoggedIn)msg(playerid, YELLOW, "**You are already logged in");
		else
		{
			new pwd[50];
			if(sscanf(params, "s[50]", pwd))
			{
				ShowPlayerDialog(playerid, d_Login, DIALOG_STYLE_PASSWORD, "Login To Your Account", "Type your password below", "Accept", "Quit");
			}
			else
			{
			    file_Open(GetFile(playerid));
			    new UserFilePW[50];
				format(UserFilePW, 50, file_GetStr("password"));
				file_Close();
				if(!strcmp(pwd, UserFilePW, true, strlen(pwd)))Login(playerid);
				else
				{
					IncorrectPass[playerid]++;
					msgF(playerid, RED, "**Incorrect Password! (%d/5 Tries) Try again", IncorrectPass[playerid]);
					if(IncorrectPass[playerid] == 5)
					{
						IncorrectPass[playerid]=0;
						Kick(playerid);
					}
				}
			}
		}
	}
	else
	{
		msgF(playerid, RED, "**You do not have a stats account yet, please type /Reg", IncorrectPass[playerid]);
	}
	return 1;
}
CMD:changename(playerid, params[])
{
	new NEW_pName[24];
 	if (sscanf(params, "s[24]", NEW_pName)) msg(playerid, YELLOW, "Usage: /changename [new name]");
	else
	{
		new nFile[35];
		format(nFile, 35, userfile, NEW_pName);
		if(fexist(nFile))
		{
			ShowPlayerDialog(playerid, d_Login, DIALOG_STYLE_PASSWORD, "This account already exists", "Type your password below", "Accept", "Quit");
		}
		else
		{
			new OLD_pName[20];
			GetPlayerName(playerid, OLD_pName, sizeof(OLD_pName));
			SetName(playerid, NEW_pName, OLD_pName);
		}
	}
	return 1;
}
SetName(playerid, newname[], oldname[])
{
	msgF(playerid, YELLOW, "**your new name is %s", newname);
	msgaF(YELLOW, "**%s has changed his name to %s", oldname, newname);
	SetPlayerName(playerid, newname);
}
CMD:changepass(playerid,params[])
{
	new newpw[50], oldpw[50];
	if (sscanf(params, "s[50]s[50]", oldpw, newpw)) return msg(playerid,YELLOW,"Usage: /changepw [old pw] [new pw]");
	else
	{
		new pFile[40];
		pFile=GetFile(playerid);

		file_Open(pFile);
		{
			new old_pwdstr[50];
			format(old_pwdstr, 50, "%s", file_GetStr("password"));

			if(!strcmp(oldpw, old_pwdstr))
			{
				file_SetStr("password", newpw);
				msgF(playerid, YELLOW, "**Password Succesfully Changed To %s!", newpw);
			}
			else
			{
				msg(playerid, RED, "The current Password you typed is wrong");
			}
		}
		file_Save(pFile);
		file_Close();
	}
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	new Menu:pMenu = GetPlayerMenu(playerid);
    script_Deathmatch_MenuRow(playerid, row, pMenu);
    script_CarMenu_MenuRow(playerid, row, pMenu);
    script_WepMenu_MenuRow(playerid, row, pMenu);
    script_MAP02_MenuRow(playerid, row, pMenu);
    script_CustomDM_MenuRow(playerid, row, pMenu);
	if(pMenu == weathermenu)
	{
		switch(row)
		{
			case 0: GlobalWeather = 11;
			case 1: GlobalWeather = 8;
			case 2: GlobalWeather = 16;
			case 3: GlobalWeather = 9;
			case 4: GlobalWeather = 19;
			case 5: GlobalWeather = 500;
			case 6: GlobalWeather = random(91);
			case 7: ShowPlayerDialog(playerid, d_Weather, DIALOG_STYLE_INPUT, "Weather", "Enter a WeatherID", "Enter", "Close");
		}
	}
	if(pMenu == m_Minigame)StartMinigame(playerid, row);
}
public OnPlayerExitedMenu(playerid)
{
	new Menu:pMenu = GetPlayerMenu(playerid);
	#define OR ||pMenu==
	if(pMenu == KitSelect)return ShowMenuForPlayer(KitSelect, playerid);
	if(pMenu == TeamSelect)return ShowMenuForPlayer(TeamSelect, playerid);
	if(pMenu == LobbyMenu)return ShowMenuForPlayer(LobbyMenu, playerid);
	#undef OR
	TogglePlayerControllable(playerid,true);
	return 1;
}

public togcont(playerid)TogglePlayerControllable(playerid, 1);
public resetcamera(playerid)SetCameraBehindPlayer(playerid);


public AnnounceMG(mg)
{
	if(mg==0)
	{
		PlayerLoop(i)
		{
			if(i!=MarkedMan)msgF(i, YELLOW, "... %s! Get Chasing Them!", GetName(MarkedMan));
			else msg(i, RED, "... {FFFF00}You!{FF0000} Get Running!!");
		}
		bitFalse(bServerGlobalSettings, CDrunning);
		StartCountdown(3, 30);
	}
	if(mg==1)
	{
		PlayerLoop(i)
		{
			if(i!=Juggernaut)msgF(i, YELLOW, "... %s! Watch out! They're a mean machine, but there's a prize for the killer!", GetName(MarkedMan));
			else msg(i, RED, "... {FFFF00}You!{FF0000} Get Hunting!!");
		}
		StartCountdown(3, 30);
	}
}


new
CARS_Poor[]=
{
	404,442,479,549,600,496,496,
	401,410,419,436,439,517,518
},
CARS_Casual[]=
{
	401,410,419,436,439,474,491,
	496,517,518,526,527,533,545,
	549,580,589,600,602,400,404,
	442,458,479,489,505,579,405,
	421,426,445,466,467,492,507,
	516,529,540,546,547,550,551,
	566,585,587,412,534,535,536,
	567,575,576
},
CARS_Expensive[]=
{
	558,559,560,561,562,565,411,
	451,477,480,494,502,503,506,
	541
},
CARS_4X4[]=
{
	400,505,579,422,478,543,554
},
CARS_Bikes[]=
{
	461,462,463,468,521,522,581,
	586
},
CARS_Custom_LasPayasdasTown[20] =
{
	589,
	600,
	439,
	482,
	543,
	402,
	445,
	478,
	439,
	439,
	549,
	549,
	600,
	404,
	505,
	458,
	401,
	542,
	554,
	605
},
CARS_Custom_LasPayasdasCarPark[7] =
{
	475,
	496,
	500,
	422,
	413,
	483,
	508
};

#define AddStaticVehicle(%0,%1,%2,%3,%4,%5,%6) AddStaticVehicleEx(%0,%1,%2,%3,%4,%5,%6,(30*60)),TotalVehicles++
LoadVehicles()
{
	print("- Loading Vehicles...");
	//Las Venturas
	{
		//Car Park
		{
			AddStaticVehicle(495,2316.1028,1388.4181,43.1285,0.6360,101,106); //
			AddStaticVehicle(560,2312.3005,1388.0067,42.5611,359.9044,21,1); //
			AddStaticVehicle(451,2308.6904,1390.1555,42.5290,179.8346,1,1); //
			AddStaticVehicle(494,2305.7449,1387.2104,42.7140,0.3950,36,117); //
			AddStaticVehicle(502,2302.2742,1389.0842,42.7290,179.4067,36,117); //
			AddStaticVehicle(502,2299.3052,1388.3203,42.7131,2.5368,36,117); //
			AddStaticVehicle(503,2295.4663,1389.1681,42.7177,0.3146,36,117); //
			AddStaticVehicle(480,2292.4500,1388.7083,42.6192,359.2972,73,45); //
			AddStaticVehicle(560,2289.3359,1388.0483,42.5549,180.3380,21,1); //
			AddStaticVehicle(421,2282.5869,1390.1288,42.7088,178.3761,0,0); //
			AddStaticVehicle(487,2275.4722,1392.6538,42.9791,358.0707,29,42); //
			AddStaticVehicle(411,2306.5237,1408.8400,42.5346,89.0548,64,1); //
			AddStaticVehicle(421,2303.9680,1415.7072,42.7081,88.2134,0,0); //
			AddStaticVehicle(451,2303.2671,1433.3424,42.5327,90.6916,1,1); //
			AddStaticVehicle(451,2303.1394,1443.9855,42.5326,90.6917,1,1); //
			AddStaticVehicle(411,2303.6934,1466.1951,42.5381,89.0548,64,1); //
			AddStaticVehicle(451,2350.6079,1468.9904,42.5370,270.6741,1,1); //
			AddStaticVehicle(451,2350.9011,1444.5618,42.4967,90.6913,1,1); //
			AddStaticVehicle(494,2351.4636,1440.8566,42.7400,272.4956,36,117); //
			AddStaticVehicle(504,2352.6345,1433.4214,42.6268,273.2388,51,39); //
			AddStaticVehicle(411,2349.7969,1429.9700,42.5389,89.0548,64,1); //
			AddStaticVehicle(411,2349.7969,1429.9702,42.5389,89.0548,64,1); //
			AddStaticVehicle(415,2350.7324,1419.1069,42.5944,87.8538,25,1); //
			AddStaticVehicle(411,2351.1064,1409.0687,42.5347,89.0547,64,1); //
			AddStaticVehicle(522,2354.4314,1401.4918,42.3869,86.9294,11,11); //
			AddStaticVehicle(522,2354.3464,1399.8983,42.3855,86.9294,11,11); //
			AddStaticVehicle(522,2354.2197,1397.5375,42.3855,86.9294,11,11); //
			AddStaticVehicle(522,2354.1265,1395.7968,42.3855,87.0016,11,11); //
			AddStaticVehicle(415,2290.9177,1418.9801,37.2230,89.1723,20,1); //
			AddStaticVehicle(415,2262.5728,1419.3958,37.2414,87.7648,0,1); //
			AddStaticVehicle(560,2305.7822,1389.4288,36.1599,180.2850,9,39); //
			AddStaticVehicle(508,2351.8398,1433.7485,34.8426,89.6257,158,236); //
			AddStaticVehicle(494,2325.1108,1448.0443,33.4421,91.4250,36,117); //
			AddStaticVehicle(560,2302.5703,1516.9219,36.1600,178.1973,52,39); //
			AddStaticVehicle(494,2263.0989,1447.9086,26.3775,83.6144,36,117); //
		}
		//The Strip
		{
			AddStaticVehicle(588,2037.7413,1471.0989,10.6012,178.5534,146,146); //
			AddStaticVehicle(463,2031.5215,1439.6752,10.3733,222.7396,11,11); //
			AddStaticVehicle(463,2031.5215,1439.6752,10.3733,222.7396,11,11); //
			AddStaticVehicle(409,2038.8901,1422.9379,10.4509,179.3443,1,1); //
			AddStaticVehicle(411,2039.7875,1343.1151,10.3905,359.5570,123,1); //
			AddStaticVehicle(413,2039.0793,1361.8251,10.7665,181.8910,91,1); //
			AddStaticVehicle(411,2038.4020,1062.8169,10.3905,1.0250,106,1); //
			AddStaticVehicle(411,2038.5464,1008.3773,10.3905,359.9242,80,1); //
			AddStaticVehicle(503,2074.7683,881.2936,7.0369,180.9418,36,117); //
			AddStaticVehicle(502,2074.8948,873.6124,6.8768,180.9400,36,117); //
			AddStaticVehicle(494,2074.5210,867.3474,6.7207,179.4656,36,117); //
			AddStaticVehicle(571,2063.4587,824.4003,6.1448,305.2674,6,6); //
			AddStaticVehicle(571,2059.2881,824.3882,6.1330,305.2426,6,6); //
			AddStaticVehicle(462,2155.0122,988.2216,10.4316,339.5848,6,151); //
			AddStaticVehicle(490,2132.7905,1006.4492,10.9580,88.6789,0,0); //
			//Caliguas
			{
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2087.9744,1694.4324,10.3006,0.0811,158,158); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2087.9836,1687.5994,10.3007,0.0821,158,158); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2151.1228,1678.4215,10.6004,356.6032,1,1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2175.7625,1692.8457,10.5036,87.9024,36,36); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2175.8071,1689.5580,10.4918,85.5022,1,2); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2175.2893,1686.0786,10.5714,87.7377,73,45); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2175.3875,1682.7247,10.4716,90.0401,58,8); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2175.8059,1679.3068,10.5917,271.1598,0,7); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2175.9019,1675.2491,10.7139,90.1315,36,117); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2175.0632,1671.1453,10.5429,92.8567,64,1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2175.0815,1667.2368,10.6130,93.2802,0,7); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2175.3079,1662.1439,10.5388,102.7194,64,1); //
			}
			//Visage Hotel
			{
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2020.6909,1898.9701,11.9686,270.6190,36,117);
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2020.8606,1902.9972,11.8680,271.6459,64,1);
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2020.4741,1907.1558,11.8399,268.2509,1,1);
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2020.9235,1911.0394,12.2464,269.8964,21,1);
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2020.5609,1914.6359,11.9859,270.9764,0,7);
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2020.5604,1918.1155,12.3251,272.0750,73,45);
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2020.7113,1921.4945,12.2439,270.6905,36,117);
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2021.0372,1925.0632,11.9865,268.2490,116,1);
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2021.0219,1928.5303,12.1952,270.0006,2,1);
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2020.7944,1932.1987,12.0206,269.8073,64,1);
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2021.1941,1935.2848,12.0843,269.2724,36,117);
			}
			//Autobahn
			{
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2148.8569,1409.2875,10.4518,185.7537,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2145.6187,1408.8789,10.4525,180.6071,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2138.8352,1409.2008,10.4516,357.3402,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2135.6814,1409.0923,10.4527,357.2116,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2132.8689,1409.1080,10.4569,177.7740,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2129.9011,1408.4214,10.4560,179.2405,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2126.0972,1408.8357,10.4527,179.3159,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2123.2788,1408.9084,10.4484,0.8792,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2119.9358,1408.3633,10.4444,0.6069,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2113.4407,1409.0208,10.4519,359.6349,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2110.6682,1408.4395,10.4526,179.1072,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2107.2900,1408.9222,10.4527,182.0358,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2100.6169,1409.1597,10.4518,356.0612,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2100.5662,1398.1571,10.4524,4.4274,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2110.2332,1397.9614,10.4674,176.5377,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2113.5129,1397.9830,10.4521,6.8346,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2116.4824,1398.1837,10.4523,358.9707,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2123.2468,1397.7813,10.4438,180.0524,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2126.4336,1399.4026,10.4911,181.1668,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2132.7217,1396.9773,10.4502,2.4539,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2135.7358,1397.6240,10.4523,356.6988,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2145.3850,1397.7853,10.4448,180.0243,-1,-1); //
				AddStaticVehicle(CARS_Expensive[random(sizeof(CARS_Expensive))],2148.7263,1398.4346,10.4444,175.9499,-1,-1); //
			}
			//Shop
			{
				AddStaticVehicle(CARS_Casual[random(sizeof(CARS_Casual))],2185.6099,1974.8805,10.4515,94.4167,-1,-1); //
				AddStaticVehicle(CARS_Casual[random(sizeof(CARS_Casual))],2171.8762,1976.7562,10.4516,89.7113,-1,-1); //
				AddStaticVehicle(CARS_Casual[random(sizeof(CARS_Casual))],2171.3440,1973.5089,10.4523,276.2142,-1,-1); //
				AddStaticVehicle(CARS_Casual[random(sizeof(CARS_Casual))],2186.6421,1979.0579,10.4524,267.6293,-1,-1); //
				AddStaticVehicle(CARS_Casual[random(sizeof(CARS_Casual))],2184.3252,1983.1555,10.4517,85.9255,-1,-1); //
				AddStaticVehicle(CARS_Casual[random(sizeof(CARS_Casual))],2185.5225,1987.6714,10.4521,90.4280,-1,-1); //
				AddStaticVehicle(CARS_Casual[random(sizeof(CARS_Casual))],2173.6008,1985.2874,10.4520,270.6554,-1,-1); //
				AddStaticVehicle(CARS_Casual[random(sizeof(CARS_Casual))],2172.4521,1988.7462,10.4528,89.1085,-1,-1); //
				AddStaticVehicle(CARS_Casual[random(sizeof(CARS_Casual))],2185.0349,1996.3038,10.4516,91.5642,-1,-1); //
				AddStaticVehicle(CARS_Casual[random(sizeof(CARS_Casual))],2171.8760,2000.3350,10.4524,88.5536,-1,-1); //
				AddStaticVehicle(CARS_Casual[random(sizeof(CARS_Casual))],2186.1484,2004.0822,10.4524,267.2514,-1,-1); //
			}
		}
		//Other
		{
			AddStaticVehicle(449,2864.7500,1272.5049,11.2473,180.0000,1,74);//Tram LV
		}
		//LV House
		{
			AddStaticVehicle(425,2801.5820,1186.8665,14.1941,359.2874,43,0);
			AddStaticVehicle(559,2764.9365,1141.0959,10.4494,359.7427,22,1);
			AddStaticVehicle(502,2768.1042,1138.3032,10.8410,1.7684,36,117);
			AddStaticVehicle(503,2773.5864,1133.4567,11.0468,356.6811,36,117);
			AddStaticVehicle(411,2770.9102,1135.1913,10.3926,357.8565,64,1);
			AddStaticVehicle(528,2774.3962,1142.9634,10.8590,43.6959,76,0);
		}
		//LV hangout
		{
			AddStaticVehicle(522,2094.7598,1165.8435,11.2259,60.8611,8,82);
			AddStaticVehicle(522,2094.2415,1164.9138,11.2259,60.8611,8,82);
			AddStaticVehicle(503,2096.2510,1286.4575,11.0494,359.6734,36,117);
		}
		//Oil Rig Heli
		{
			AddStaticVehicle(487,3244.4485,2672.3750,29.7803,0.1012,3,29);
		}
		//LV stunt Park
		{
			AddStaticVehicle(411,1343.9009,1807.8611,42.5506,89.5974,125,125); //
			AddStaticVehicle(560,1343.7605,1811.2129,42.5496,91.3088,125,125); //
			AddStaticVehicle(559,1344.2412,1814.6355,42.5508,89.0531,125,125); //
			AddStaticVehicle(429,1344.0702,1817.7655,42.5519,90.6102,125,125); //
			AddStaticVehicle(451,1344.1477,1821.3004,42.5503,89.1929,125,125); //
			AddStaticVehicle(477,1343.6281,1824.6407,42.5508,90.4542,125,125); //
			AddStaticVehicle(480,1343.9706,1828.0342,42.5507,90.4371,125,125); //
			AddStaticVehicle(434,1344.4657,1831.3989,42.5510,89.0587,125,125); //
			AddStaticVehicle(506,1344.8148,1834.6172,42.5511,91.1747,125,125); //
			AddStaticVehicle(555,1344.3303,1837.9568,42.5523,91.7862,125,125); //
			AddStaticVehicle(541,1344.8983,1841.1433,42.5510,92.8831,125,125); //
		}
	}
	//LV City End


	//Desert
	{
		//Army base
		{
			AddStaticVehicle(520,307.9320,2054.2683,18.7000,178.4052,0,0);
			AddStaticVehicle(520,328.1882,1981.7871,18.6573,132.5052,0,0);
			AddStaticVehicle(520,328.2762,1965.3821,18.6573,132.5052,0,0);
			AddStaticVehicle(520,327.8918,1947.5223,18.6573,132.5052,0,0);
			AddStaticVehicle(520,328.0760,1933.9165,18.6573,132.5052,0,0);
			AddStaticVehicle(432,275.4779,2018.8108,17.7527,269.2920,43,0);
			AddStaticVehicle(432,275.5724,2026.4744,17.7793,269.2920,43,0);
			AddStaticVehicle(433,281.3487,1984.1102,18.0773,269.7641,0,0);
			AddStaticVehicle(433,281.3648,1988.0114,18.0773,269.7641,0,0);
			AddStaticVehicle(433,281.3933,1994.9532,18.0773,269.7641,0,0);
			AddStaticVehicle(470,281.2079,1949.9275,18.0773,269.7641,0,0);
			AddStaticVehicle(470,281.2214,1953.1849,18.0773,269.7641,0,0);
			AddStaticVehicle(470,281.2429,1958.3960,18.0773,269.7641,0,0);
		}
		//Town Near Gas Station
		{
			AddStaticVehicle(458,676.4833,1946.5837,5.4176,177.9135,101,1); //
			AddStaticVehicle(482,681.5339,1946.3915,5.6583,179.3121,48,48); //
			AddStaticVehicle(439,691.1129,1945.2899,5.4350,186.3769,8,17); //
			AddStaticVehicle(515,721.3881,1946.3853,6.5578,173.9754,24,77); //
			AddStaticVehicle(600,726.8625,1945.9319,5.2518,2.5536,32,8); //
		}
		//Las Payasdas
		{
			AddStaticVehicle(609,-318.0690,2663.7947,63.1075,0.9959,36,36); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-224.5601,2695.9822,62.2693,271.4700,31,31); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-205.6529,2706.0859,62.3249,269.5905,43,8); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-262.4421,2660.7632,62.5056,359.6135,25,78); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-278.7728,2688.3071,62.7955,0.8800,64,64); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-295.2684,2667.2480,62.4566,87.4715,32,8); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-198.3039,2594.6716,62.5347,177.6167,22,22); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-216.6689,2595.6868,62.5781,0.3146,41,41); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-201.1363,2608.8044,62.6965,179.0554,66,1); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-163.4358,2773.6926,62.5790,4.3154,54,38); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-163.4358,2773.6926,62.5790,4.3154,54,38); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-155.0388,2756.1689,62.3329,233.5874,72,39); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-199.3787,2780.7896,61.7205,87.9703,72,39); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-237.3706,2814.4324,61.4218,1.1834,43,8); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-258.9815,2778.9248,62.2897,268.3802,3,1); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-283.3362,2756.2231,62.3657,179.6650,14,123); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-306.9199,2719.2234,62.5298,180.9773,109,1); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-282.6340,2739.1323,61.9810,358.1460,47,47); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-276.1412,2719.6328,62.3535,175.7664,32,92); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-300.3122,2689.5798,62.7596,358.7992,15,32); //
			AddStaticVehicle(CARS_Custom_LasPayasdasTown[random(sizeof(CARS_Custom_LasPayasdasTown))],-151.2221,2812.3894,87.4474,54.3155,32,8); //
			AddStaticVehicle(CARS_Custom_LasPayasdasCarPark[random(sizeof(CARS_Custom_LasPayasdasCarPark))],-237.8381,2594.7124,62.6137,179.9804,17,1); //
			AddStaticVehicle(CARS_Custom_LasPayasdasCarPark[random(sizeof(CARS_Custom_LasPayasdasCarPark))],-237.8381,2594.7124,62.6137,179.9804,17,1); //
			AddStaticVehicle(CARS_Custom_LasPayasdasCarPark[random(sizeof(CARS_Custom_LasPayasdasCarPark))],-225.8945,2595.6257,62.4191,1.9840,66,72); //
			AddStaticVehicle(CARS_Custom_LasPayasdasCarPark[random(sizeof(CARS_Custom_LasPayasdasCarPark))],-237.1931,2608.8540,62.8058,1.7679,40,84); //
			AddStaticVehicle(CARS_Custom_LasPayasdasCarPark[random(sizeof(CARS_Custom_LasPayasdasCarPark))],-231.4445,2609.1448,62.6919,180.4073,83,57); //
			AddStaticVehicle(CARS_Custom_LasPayasdasCarPark[random(sizeof(CARS_Custom_LasPayasdasCarPark))],-213.3429,2609.0676,62.7941,0.1546,105,1); //
			AddStaticVehicle(CARS_Custom_LasPayasdasCarPark[random(sizeof(CARS_Custom_LasPayasdasCarPark))],-219.8046,2595.6470,62.6953,178.5970,1,31); //
			AddStaticVehicle(CARS_Custom_LasPayasdasCarPark[random(sizeof(CARS_Custom_LasPayasdasCarPark))],-210.5002,2594.8528,63.0778,178.2449,1,1); //
		}
		//The Big Ear
		{
			AddStaticVehicle(437,-303.7336,1554.6400,75.4915,44.4410,79,7);
			AddStaticVehicle(559,-305.0596,1582.0848,74.9765,134.0336,60,1);
			AddStaticVehicle(541,-302.4808,1580.0264,75.0039,134.8949,51,1);
			AddStaticVehicle(411,-300.3009,1577.2799,74.9326,132.7428,123,1);
			AddStaticVehicle(429,-298.1730,1574.0070,75.2355,133.4759,2,1);
			AddStaticVehicle(560,-295.3154,1572.1420,75.3035,133.9668,41,29);
			AddStaticVehicle(494,-292.4744,1569.9791,75.0333,136.0669,92,101);
			AddStaticVehicle(400,-282.9085,1559.8799,75.0711,134.2065,53,53);
			AddStaticVehicle(568,-277.8745,1554.9503,75.2269,132.4450,37,0);
			AddStaticVehicle(415,-274.2900,1553.3563,75.0251,133.5830,62,1);
			AddStaticVehicle(502,-289.9839,1567.3138,75.2631,134.1981,36,117);
			AddStaticVehicle(503,-287.3968,1565.0713,75.1332,136.1444,36,117);
			AddStaticVehicle(451,-285.1379,1562.3457,75.9029,136.5349,36,36);
			AddStaticVehicle(504,-280.2895,1557.4237,75.1520,134.1389,51,39);
			AddStaticVehicle(587,-272.0986,1550.6173,75.9319,134.1637,64,1);
			AddStaticVehicle(495,-262.8809,1541.1262,75.9149,134.1636,64,1);
			AddStaticVehicle(542,-269.7327,1548.1777,75.0942,134.1637,64,1);
			AddStaticVehicle(549,-267.3824,1545.7579,75.0942,134.1637,64,1);
			AddStaticVehicle(480,-265.3483,1543.2670,75.1945,135.2411,73,45);
		}
		//Bayside fishing village
		{
			AddStaticVehicle(429,-2450.0352,2225.4893,4.5379,2.7546,2,1);
			AddStaticVehicle(411,-2443.6875,2224.5879,4.4160,356.7347,64,1);
			AddStaticVehicle(560,-2446.6001,2225.6541,4.5515,359.9999,33,0);
			AddStaticVehicle(415,-2452.9792,2224.8850,4.6187,0.0105,0,7);
			AddStaticVehicle(502,-2455.7625,2224.6128,4.7465,0.3668,36,117);
			AddStaticVehicle(541,-2458.7961,2224.8423,4.4906,1.1807,51,1);
			AddStaticVehicle(503,-2461.7498,2225.1292,4.6178,359.9307,36,117);
			AddStaticVehicle(494,-2464.8997,2224.5781,4.5163,0.3630,36,117);
			AddStaticVehicle(559,-2467.7705,2224.7065,4.4607,359.1031,60,1);
			AddStaticVehicle(558,-2470.6777,2225.1233,4.4914,358.9154,116,1);
			AddStaticVehicle(402,-2473.6858,2224.7861,4.8579,358.7800,252,252);
			AddStaticVehicle(451,-2476.8958,2224.6475,4.3897,1.6484,1,1);
			AddStaticVehicle(480,-2479.6904,2224.5356,4.6109,358.7395,73,45);
			AddStaticVehicle(568,-2482.6467,2224.0532,4.7086,358.0612,37,0);
			AddStaticVehicle(587,-2485.7666,2224.7402,4.5330,358.1873,64,1);
			AddStaticVehicle(555,-2485.5454,2242.1121,4.5275,359.4656,58,1);
			AddStaticVehicle(543,-2482.5173,2242.1460,4.6613,0.1016,32,8);
			AddStaticVehicle(475,-2479.5171,2241.8464,4.7263,359.9187,252,252);
			AddStaticVehicle(421,-2446.7542,2241.9602,4.7404,0.1653,0,0);
			AddStaticVehicle(575,-2443.8259,2242.5461,4.4831,1.6586,19,96);
			AddStaticVehicle(413,-2440.8110,2241.8997,4.9300,1.0702,0,0);
			AddStaticVehicle(542,-2449.8669,2241.9141,4.5370,359.9318,64,1);
			AddStaticVehicle(549,-2452.8374,2242.3972,4.4753,0.5156,64,1);
			AddStaticVehicle(400,-2475.9690,2242.0771,4.9345,0.1609,53,53);
			AddStaticVehicle(487,-2227.6382,2324.8667,7.6861,0.0050,29,42);
		}
		//Cliff helis
		{
			AddStaticVehicle(487,-2568.2686,2887.9758,97.4596,83.3394,29,42);//cliff1
			AddStaticVehicle(487,-2034.3693,2952.6130,58.2810,88.1607,29,42);//cliff2
			AddStaticVehicle(487,-1771.2999,2925.0332,57.3893,265.0977,29,42);//cliff3
			AddStaticVehicle(487,-1491.5854,2953.5393,45.8934,286.7923,29,42);//cliff4
		}
		//El Quebrados
		{
			AddStaticVehicle(416,-1509.7880,2525.1982,55.8366,180.5040,1,3);
			AddStaticVehicle(416,-1506.9133,2525.2327,55.8198,180.6379,1,3);
			AddStaticVehicle(555,-1500.5602,2525.4690,55.3720,3.3392,58,1);
			AddStaticVehicle(599,-1399.9288,2656.3745,55.8744,269.4020,0,1);
			AddStaticVehicle(599,-1399.9893,2650.5706,55.8745,269.4020,0,1);
			AddStaticVehicle(413,-1517.4840,2569.0471,55.9215,89.7040,0,0);
			AddStaticVehicle(543,-1476.4001,2693.5508,55.5791,355.7510,32,8);
			AddStaticVehicle(475,-1565.1898,2647.4163,55.6433,86.1194,37,0);
			AddStaticVehicle(542,-1596.0840,2696.4048,54.8126,181.4943,64,1);
			AddStaticVehicle(508,-1593.6014,2653.3198,56.1302,0.7595,158,236);
		}
		//town in desert [west]
		{
			AddStaticVehicle(468,-1458.8889,2619.2656,55.5041,358.5864,11,11);
			AddStaticVehicle(468,-1460.7175,2618.7537,55.4989,358.5861,11,11);
		}
		//cagatay's map in desert
		{
		   	AddStaticVehicle(487,-64.4650,2494.9041,16.6616,270.6709,12,39); // heli
		}
	}
	//Desert End


	//Country
	{
		//rally track
		{
			AddStaticVehicle(503,1561.2334,18.3367,23.9377,182.3313,36,117);
			AddStaticVehicle(560,1557.6045,17.3907,24.1058,187.7425,41,29);
		}
		//Missionary Hill
		{
			AddStaticVehicle(411,-2416.9751,-588.8193,132.2206,35.6204,64,1);
			AddStaticVehicle(411,-2397.3933,-611.0465,132.2384,35.6203,64,1);
			AddStaticVehicle(560,-2414.2891,-587.1630,132.5911,34.6816,21,1);
			AddStaticVehicle(560,-2395.1223,-609.1028,132.7022,34.6816,21,1);
			AddStaticVehicle(451,-2411.8523,-585.3640,132.1907,34.3945,36,36);
			AddStaticVehicle(451,-2392.4746,-607.3971,132.5384,34.3945,36,36);
			AddStaticVehicle(429,-2409.2058,-583.5032,132.5042,34.8660,2,1);
			AddStaticVehicle(429,-2399.8533,-612.8764,132.5044,34.8660,2,1);
			AddStaticVehicle(503,-2403.5146,-585.2468,132.4215,124.1052,36,117);
			AddStaticVehicle(503,-2391.9631,-602.3055,132.4374,124.1052,36,117);
		}
		//gas stop in country south country island
		{
			AddStaticVehicle(CARS_4X4[random(sizeof(CARS_4X4))],-1576.3865,-2729.2598,48.4475,142.7650,6,117);
			AddStaticVehicle(CARS_4X4[random(sizeof(CARS_4X4))],-1560.5929,-2740.5466,48.1877,145.0505,116,1);
			AddStaticVehicle(CARS_4X4[random(sizeof(CARS_4X4))],-1558.3884,-2742.2859,48.5564,144.4889,252,252);
			AddStaticVehicle(CARS_Poor[random(sizeof(CARS_Poor))],-1569.4703,-2733.8159,48.4097,324.7454,37,0);
			AddStaticVehicle(CARS_Poor[random(sizeof(CARS_Poor))],-1564.8541,-2736.8958,48.2276,324.9351,58,1);
		}
		//Races
		{
			//Rally1
			AddStaticVehicle(503,-548.3710,-192.5190,78.1798,270.1662,36,117);
			AddStaticVehicle(560,-547.3762,-189.4697,78.3489,270.2634,21,1);
			AddStaticVehicle(502,-547.8911,-186.4032,78.3110,268.6143,36,117);
			//Race3
			AddStaticVehicle(503,-894.6573,-1116.7847,98.6998,42.6336,36,117);
			AddStaticVehicle(502,-890.6454,-1113.0131,98.8617,42.8862,36,117);
			AddStaticVehicle(522,-899.3032,-1109.7269,98.3383,41.3401,11,11);
			AddStaticVehicle(522,-897.4515,-1108.0977,98.3384,41.3401,11,11);
			AddStaticVehicle(522,-895.2381,-1106.1503,98.3386,41.3401,11,11);
			AddStaticVehicle(522,-901.5578,-1111.7101,98.3382,41.3401,11,11);
			//Drift3
			AddStaticVehicle(411,-771.9290,-1724.7710,96.0559,345.1448,64,1);
			AddStaticVehicle(502,-766.8187,-1727.1337,96.3535,346.7087,36,117);
		}
		//chilliad
		{
			AddStaticVehicle(584,-2334.6941,-1586.4933,483.5523,242.6853,36,117);//trailer
			AddStaticVehicle(584,-2337.3848,-1591.7025,483.5709,242.6853,36,117);//trailer
			AddStaticVehicle(584,-2340.1816,-1597.1180,483.5902,242.6853,36,117);//trailer
			AddStaticVehicle(515,-2331.0662,-1601.7144,484.7831,240.8797,54,77);//truck
			AddStaticVehicle(515,-2328.4241,-1596.3340,484.7797,242.2337,54,77);//truck
			AddStaticVehicle(515,-2325.4810,-1590.1842,484.7545,247.6842,54,77);//truck
		}
	}
	//Country End


	//San Fierro
	{
		//SF City
		{
			AddStaticVehicle(402, -2021.1729, 906.5520, 46.7648, 269.8416, -1, -1); //Buffalo
			AddStaticVehicle(402, -2011.8447, 879.9290, 45.3831, 179.2091, -1, -1); //Buffalo
			AddStaticVehicle(402, -1948.4398, 793.5240, 55.7387, 272.5092, -1, -1); //Buffalo
			AddStaticVehicle(402, -2284.3032, 727.5042, 49.4528, 269.7318, -1, -1); //Buffalo
			AddStaticVehicle(402, -1659.1338, 757.2385, 18.0645, 183.0124, -1, -1); //Buffalo
			AddStaticVehicle(402, -1628.6479, 651.3251, 7.2009, 359.9722, -1, -1); //Buffalo
			AddStaticVehicle(402, -1535.3909, 760.0492, 7.1217, 355.7692, -1, -1); //Buffalo
			AddStaticVehicle(402, -1906.5951, 825.4506, 35.1017, 181.2765, -1, -1); //Buffalo
			AddStaticVehicle(402, -2021.2156, 558.8962, 35.1023, 272.0281, -1, -1); //Buffalo
			AddStaticVehicle(402, -2011.2209, 459.3321, 35.1063, 178.1403, -1, -1); //Buffalo
			AddStaticVehicle(402, -1987.6460, 276.2277, 35.1923, 89.6567, -1, -1); //Buffalo
			AddStaticVehicle(411, -1988.0007, 272.9730, 34.7187, 87.3158, -1, -1); //Infernus
			AddStaticVehicle(560, -1988.7672, 269.5150, 35.1150, 86.1324, -1, -1); //Sultan
			AddStaticVehicle(415, -1989.6541, 266.5012, 34.8305, 83.3440, -1, -1); //Cheetah
			AddStaticVehicle(502, -1989.6244, 263.3276, 35.0894, 80.7791, -1, -1); //Hotring Racer
			AddStaticVehicle(559, -1990.2373, 260.1350, 34.7966, 84.0841, -1, -1); //Jester
			AddStaticVehicle(541, -1990.6254, 255.4747, 34.8164, 82.0248, -1, -1); //Bullet
			AddStaticVehicle(558, -1991.0797, 252.2954, 34.8133, 82.2015, -1, -1); //Uranus
			AddStaticVehicle(503, -1991.7175, 249.1381, 34.9368, 78.5333, -1, -1); //Hotring Racer
			AddStaticVehicle(494, -1992.6898, 240.6869, 34.8463, 85.3390, -1, -1); //Hotring Racer
			AddStaticVehicle(451, -1992.4490, 244.7847, 34.7149, 82.5787, -1, -1); //Turismo
			AddStaticVehicle(503, -1996.3661, 391.1114, 34.8651, 2.4751, -1, -1); //Hotring Racer
			AddStaticVehicle(503, -2044.2429, 499.7074, 34.8561, 89.9804, -1, -1); //Hotring Racer
			AddStaticVehicle(503, -2151.4104, 446.7505, 34.8645, 179.7327, -1, -1); //Hotring Racer
			AddStaticVehicle(503, -2066.5059, 386.6081, 34.9449, 270.8270, -1, -1); //Hotring Racer
			AddStaticVehicle(503, -1968.2542, 738.5436, 45.1430, 88.3616, -1, -1); //Hotring Racer
			AddStaticVehicle(502, -2030.0427, 725.5587, 49.7377, 268.0220, -1, -1); //Hotring Racer
			AddStaticVehicle(502, -1929.5865, 598.2878, 34.9929, 267.3342, -1, -1); //Hotring Racer
			AddStaticVehicle(502, -1932.4120, 585.0189, 35.0307, 1.4434, -1, -1); //Hotring Racer
			AddStaticVehicle(502, -2011.8107, 486.4604, 34.9928, 179.7583, -1, -1); //Hotring Racer
			AddStaticVehicle(502, -1996.6349, 492.8254, 34.9915, 177.2022, -1, -1); //Hotring Racer
			AddStaticVehicle(502, -2024.7333, 156.8660, 33.8419, 267.0989, -1, -1); //Hotring Racer
			AddStaticVehicle(502, -1992.3154, 91.1167, 27.5868, 46.2061, -1, -1); //Hotring Racer
			AddStaticVehicle(502, -2093.3303, -83.8139, 35.0740, 1.2037, -1, -1); //Hotring Racer
			AddStaticVehicle(411, -2089.7058, -83.8353, 34.7357, 359.9932, -1, -1); //Infernus
			AddStaticVehicle(560, -2076.6245, -84.6628, 35.1054, 357.6299, -1, -1); //Sultan
			AddStaticVehicle(541, -2068.6177, -82.9608, 35.0242, 0.0001, -1, -1); //Bullet
			AddStaticVehicle(560, -2127.3577, 918.1513, 79.8467, 268.4902, -1, -1); //Sultan
		}
		//San Fierro Airport
		{
			AddStaticVehicle(417,-1186.3390,25.5713,15.1315,44.9673,2,2);//
			AddStaticVehicle(487,-1223.2577,-11.3052,15.1315,44.9673,2,2);//
			AddStaticVehicle(425,-1217.2078,184.9962,15.1315,44.9673,2,2);//
			AddStaticVehicle(417,-1237.3557,164.8708,15.1315,44.9673,2,2);//
			AddStaticVehicle(548,-1254.2744,147.9715,15.1315,44.9673,2,2);//
			AddStaticVehicle(548,-1546.8734,-248.8341,15.1315,44.9673,2,2);//
			AddStaticVehicle(417,-1505.1985,-241.8201,15.1315,10.4073,2,2);//
			AddStaticVehicle(592,-1654.2194,-161.6054,15.0697,315.2921,1,1);//
			AddStaticVehicle(520,-1352.6626,-474.9842,16.3252,173.3595,0,0);//
			AddStaticVehicle(520,-1382.5448,-490.5077,16.2552,236.1794,0,0);//
			AddStaticVehicle(520,-1363.2858,-489.3977,15.3248,205.0024,0,0);//
			AddStaticVehicle(476,-1443.1493,-524.0515,14.7421,203.8389,1,6);//
			AddStaticVehicle(593,-1430.0734,-508.8086,14.6331,167.5010,60,1);//
			AddStaticVehicle(487,-1461.5272,-523.5648,14.5786,223.1452,29,42);
		}
		//Outskirts [races etc]
		{
			//bridge bikes
			AddStaticVehicle(568,810.7485,843.0159,9.7811,110.8418,37,0);
			AddStaticVehicle(568,689.1106,894.6517,-39.5067,99.7822,37,0);
			AddStaticVehicle(522,-1255.2021,954.8159,138.8394,315.9181,11,11);
			AddStaticVehicle(522,-1279.3617,977.1333,138.7474,135.8397,11,11);
			//bridge race 1 [/drag1]
			AddStaticVehicle(411,-2694.8916,1272.1844,55.0018,359.1201,64,1);
			AddStaticVehicle(451,-2686.1489,1271.8472,54.9725,358.6759,1,1);
			AddStaticVehicle(415,-2676.9438,1271.8324,55.0935,0.0098,0,7);
			AddStaticVehicle(429,-2668.0176,1272.0282,55.2855,0.6280,2,1);
			AddStaticVehicle(503,-2686.5464,1248.8936,55.2016,358.8189,36,117);
			AddStaticVehicle(560,-2692.2991,1247.5671,55.3730,8.9444,21,1);
			AddStaticVehicle(502,-2675.0769,1247.9189,55.3337,5.1834,36,117);
			AddStaticVehicle(494,-2669.5120,1248.0164,55.1035,1.4619,36,117);
			AddStaticVehicle(559,-2669.0798,1240.1467,55.0469,3.4539,60,1);
			AddStaticVehicle(587,-2674.3948,1239.7792,55.1184,9.0803,64,1);
			AddStaticVehicle(558,-2685.2083,1238.5054,55.0725,11.4089,116,1);
			AddStaticVehicle(541,-2689.8450,1237.7076,55.0742,14.5518,51,1);
			//bridge race 2 (/drag2)
			AddStaticVehicle(411,-1124.2919,1100.5833,37.6704,134.0741,64,1);
			AddStaticVehicle(451,-1128.7618,1104.9240,37.6480,138.7440,1,1);
			AddStaticVehicle(415,-1135.5950,1111.8912,37.7520,134.1529,0,7);
			AddStaticVehicle(559,-1140.4504,1116.1139,37.7122,138.8975,60,1);
		}
	}
	//Los Santos
	{
		//LS circit cars
		{
			AddStaticVehicle(451,2203.4551,309.6419,32.6136,270.2653,36,36);
			AddStaticVehicle(451,2203.1448,314.7808,32.6141,269.3243,36,36);
			AddStaticVehicle(451,2202.1902,322.4273,32.6190,268.5643,36,36);
			AddStaticVehicle(451,2203.1624,327.4510,32.6149,267.1448,36,36);
			AddStaticVehicle(494,2192.9387,327.4775,33.0526,268.1448,98,109);
			AddStaticVehicle(494,2192.8213,322.3545,33.0544,271.0645,98,109);
			AddStaticVehicle(494,2189.9258,314.5465,33.0861,270.8532,98,109);
			AddStaticVehicle(494,2188.5557,309.6344,33.1019,270.0071,98,109);
		}
		//LS House
		{
			AddStaticVehicle(587,2970.0193,-928.9776,11.5233,176.3544,95,1);
			AddStaticVehicle(425,3021.8521,-928.6566,15.7977,0.3365,43,0);
		}
	}
	//Trains
	{
		AddStaticVehicle(538,-1943.0042,164.8620,27.0006,356.8379,1,1);
		AddStaticVehicle(538,741.2763,1943.3096,7.5664,0.4492,1,1);
	}
	//BigJump1
	{
		AddStaticVehicle(411,1461.1904,2760.2366,716.5170+10,269.5890,75,1); //
		AddStaticVehicle(411,1473.5134,2771.5874,716.5099+10,358.5232,75,1); //
		AddStaticVehicle(411,1485.3650,2772.4795,716.5092+10,178.2754,75,1); //
		AddStaticVehicle(402,1479.1473,2772.1638,716.7003+10,179.5457,13,13); //
		AddStaticVehicle(402,1471.4141,2753.8218,716.7003+10,89.1042,13,13); //
		AddStaticVehicle(402,1490.1786,2744.1521,716.7004+10,270.1200,13,13); //
		AddStaticVehicle(541,1467.3894,2772.5459,715.9977+10,359.7847,13,8); //
		AddStaticVehicle(541,1471.4454,2731.4448,715.9973+10,92.8716,13,8); //
		AddStaticVehicle(541,1490.3441,2718.4368,715.9976+10,271.5487,13,8); //
		AddStaticVehicle(451,1471.9260,2724.9451,716.6412+10,91.7097,46,46); //
		AddStaticVehicle(451,1461.9009,2705.7349,716.6439+10,271.3053,46,46); //
		AddStaticVehicle(451,1490.6825,2709.0803,716.6429+10,91.1095,46,46); //
		AddStaticVehicle(506,1479.8927,2734.5845,716.5684+10,88.9019,6,6); //
		AddStaticVehicle(506,1489.6801,2760.1587,716.5683+10,88.9320,6,6); //
	}
	//HugeJump
	{
		AddStaticVehicle(411,-1313.1521,3670.8516,4000+10,270.7491,123,1); //
		AddStaticVehicle(402,-1312.8340,3674.0615,4000+10,270.7760,22,22); //
		AddStaticVehicle(451,-1314.0547,3677.2258,4000+10,89.9599,36,36); //
		AddStaticVehicle(506,-1313.2831,3680.2432,4000+10,273.8412,52,52); //
		AddStaticVehicle(480,-1313.1722,3683.3721,4000+10,88.9386,4,4); //
		AddStaticVehicle(477,-1312.9294,3686.7266,4000+10,90.0149,94,1); //
		AddStaticVehicle(541,-1313.1613,3689.9041,4000+10,268.4594,68,8); //
		AddStaticVehicle(415,-1313.1431,3692.9844,4000+10,91.5265,25,1); //
		AddStaticVehicle(502,-1314.2224,3696.2478,4000+10,268.9412,36,88); //
		AddStaticVehicle(503,-1313.8040,3699.7712,4000+10,271.8923,98,83); //
		AddStaticVehicle(429,-1318.4980,3707.8665,4000+10,179.7469,1,3); //
		AddStaticVehicle(587,-1321.8719,3708.1431,4000+10,0.8619,95,1); //
		AddStaticVehicle(434,-1325.1274,3707.1311,4000+10,358.1499,12,12); //
		AddStaticVehicle(494,-1328.1665,3708.2983,4000+10,180.4271,36,13); //
		AddStaticVehicle(559,-1331.5117,3707.3906,4000+10,358.5717,58,8); //
		AddStaticVehicle(560,-1334.4738,3707.5356,4000+10,0.9042,52,39); //
		AddStaticVehicle(565,-1342.2000,3698.6023,4000+10,89.9533,42,42); //
		AddStaticVehicle(562,-1342.3914,3701.8074,4000+10,268.7605,11,1); //
		AddStaticVehicle(603,-1360.9109,3684.6750,4000+10,89.6548,69,1); //
		AddStaticVehicle(542,-1360.8328,3681.3452,4000+10,90.0626,13,118); //
		AddStaticVehicle(561,-1360.8945,3678.2314,4000+10,92.6576,54,38); //
		AddStaticVehicle(556,-1360.3134,3673.6165,4001+10,269.5869,1,1); //
		AddStaticVehicle(556,-1360.9482,3667.2397,4001+10,273.3577,1,1); //
		AddStaticVehicle(424,-1360.6993,3658.7615,4000+10,89.1143,2,2); //
		AddStaticVehicle(571,-1362.1772,3656.0227,3999+10,92.7135,36,2); //
		AddStaticVehicle(571,-1362.4293,3653.9099,3999+10,80.0953,36,2); //
		AddStaticVehicle(487,-1348.3119,3608.0442,3998+10,357.0424,29,42); // Helicopter
		// - Bikes
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1333.3638,3662.8269,4000+10,359.6235,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1333.2767,3665.5417,4000+10,359.8206,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1333.2307,3670.0862,4000+10,359.2613,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1333.2029,3672.2654,4000+10,359.2614,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1333.1660,3675.1345,4000+10,359.2615,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1333.1182,3678.8826,4000+10,359.2614,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1333.0782,3681.9739,4000+10,359.2615,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1333.0366,3685.2166,4000+10,359.2616,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1321.0437,3685.1895,4000+10,180.7110,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1321.0339,3682.1587,4000+10,180.0336,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1321.1300,3678.7737,4000+10,180.6140,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1321.0483,3676.1304,4000+10,180.2004,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1321.0367,3672.7861,4000+10,180.2002,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1321.0249,3669.3987,4000+10,180.2001,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1321.0131,3666.0505,4000+10,180.2000,39,106); //
		AddStaticVehicle(CARS_Bikes[random(sizeof(CARS_Bikes))],-1321.0038,3663.3245,4000+10,180.1999,39,106); //
	}
////////////////////////////////////////////////////////////////////////////////
//LAS VENTURAS
	FileLoadedVehicles += LoadVehiclesFromFile("vehicles/lv_law.txt");
	FileLoadedVehicles += LoadVehiclesFromFile("vehicles/lv_gen.txt");

/*
//SAN FIERRO
//	FileLoadedVehicles += LoadStaticVehiclesFromFile("vehicles/sf_law.txt");
	FileLoadedVehicles += LoadStaticVehiclesFromFile("vehicles/sf_gen.txt");

//LOS SANTOS
	FileLoadedVehicles += LoadStaticVehiclesFromFile("vehicles/ls_law.txt");
//	FileLoadedVehicles += LoadStaticVehiclesFromFile("vehicles/ls_airport.txt");
	FileLoadedVehicles += LoadStaticVehiclesFromFile("vehicles/ls_gen_inner.txt");
//	FileLoadedVehicles += LoadStaticVehiclesFromFile("vehicles/ls_gen_outer.txt");

//OTHER AREAS
	FileLoadedVehicles += LoadStaticVehiclesFromFile("vehicles/whetstone.txt");
	FileLoadedVehicles += LoadStaticVehiclesFromFile("vehicles/bone.txt");
	FileLoadedVehicles += LoadStaticVehiclesFromFile("vehicles/flint.txt");
	FileLoadedVehicles += LoadStaticVehiclesFromFile("vehicles/tierra.txt");
	FileLoadedVehicles += LoadStaticVehiclesFromFile("vehicles/red_county.txt");
////////////////////////////////////////////////////////////////////////////////
*/
}
LoadTextDraws()
{
	print("- Loading TextDraws...");
//=========================================================================Score
	ScoreBox				=TextDrawCreate(20.0, 280.0, " Raven: 0/10~n~   Valor: 0/10");
	TextDrawUseBox			(ScoreBox, 1);
	TextDrawBoxColor		(ScoreBox, 0x00000033);
	TextDrawTextSize		(ScoreBox, 158.000000,10.000000);
	TextDrawAlignment		(ScoreBox, 0);
	TextDrawBackgroundColor	(ScoreBox, 0x000000ff);
	TextDrawFont			(ScoreBox, 1);
	TextDrawLetterSize		(ScoreBox, 0.5, 1.6);
	TextDrawColor			(ScoreBox, 0xffffffff);
	TextDrawSetOutline		(ScoreBox, 1);
	TextDrawSetProportional	(ScoreBox, 1);
	TextDrawSetShadow		(ScoreBox, 1);

//==================================================================Score Status
	ScoreStatus_Winning		=TextDrawCreate(20.0, 260.0, "Winning");
	TextDrawBackgroundColor	(ScoreStatus_Winning, BLACK);
	TextDrawFont			(ScoreStatus_Winning, 1);
	TextDrawLetterSize		(ScoreStatus_Winning, 0.5, 1.6);
	TextDrawSetOutline		(ScoreStatus_Winning, 1);
	ScoreStatus_Tie			=TextDrawCreate(20.0, 260.0, "Tie");
	TextDrawBackgroundColor	(ScoreStatus_Tie, BLACK);
	TextDrawFont			(ScoreStatus_Tie, 1);
	TextDrawLetterSize		(ScoreStatus_Tie, 0.5, 1.6);
	TextDrawSetOutline		(ScoreStatus_Tie, 1);
	ScoreStatus_Losing		=TextDrawCreate(20.0, 260.0, "Losing");
	TextDrawBackgroundColor	(ScoreStatus_Losing, BLACK);
	TextDrawFont			(ScoreStatus_Losing, 1);
	TextDrawLetterSize		(ScoreStatus_Losing, 0.5, 1.6);
	TextDrawSetOutline		(ScoreStatus_Losing, 1);

//=========================================================================Lobby
	LobbyText				=TextDrawCreate(600.000000,245.000000,"99 Players In Lobby~n~Type /joindm to join");
	TextDrawAlignment		(LobbyText,3);
	TextDrawBackgroundColor	(LobbyText,0x000000ff);
	TextDrawFont			(LobbyText,3);
	TextDrawLetterSize		(LobbyText,0.399999,1.599999);
	TextDrawColor			(LobbyText,0x00ff00ff);
	TextDrawSetOutline		(LobbyText,1);
	TextDrawSetProportional	(LobbyText,1);
	TextDrawSetShadow		(LobbyText,1);

//====================================================================SpawnCount
	SpawnCount				=TextDrawCreate(600.000000,245.000000,"Spawning in 10");
	TextDrawAlignment		(SpawnCount, 3);
	TextDrawBackgroundColor	(SpawnCount, 0x000000ff);
	TextDrawFont			(SpawnCount, 3);
	TextDrawLetterSize		(SpawnCount, 0.399999, 1.599999);
	TextDrawColor			(SpawnCount, 0x00ff00ff);
	TextDrawSetOutline		(SpawnCount, 1);
	TextDrawSetProportional	(SpawnCount, 1);
	TextDrawSetShadow		(SpawnCount, 1);

//====================================================================Match Time
	MatchTimeCounter		=TextDrawCreate(20.0, 240.0, "00:00");
	TextDrawBackgroundColor	(MatchTimeCounter, 255);
	TextDrawUseBox			(MatchTimeCounter, 1);
	TextDrawBoxColor		(MatchTimeCounter, 0x00000033);
	TextDrawTextSize		(MatchTimeCounter, 70.000000, 0.000000);
	TextDrawFont			(MatchTimeCounter, 3);
	TextDrawLetterSize		(MatchTimeCounter, 0.5, 1.8);
	TextDrawColor			(MatchTimeCounter, 0xffffffff);
	TextDrawSetProportional	(MatchTimeCounter, 1);
	TextDrawSetShadow		(MatchTimeCounter, 1);
	TextDrawSetOutline		(MatchTimeCounter, 1);

//=====================================================================RaceLobby
    RaceCountDownText = TextDrawCreate(600.000000,300.000000,"Race Starting In 30");
	TextDrawAlignment(RaceCountDownText,3);
	TextDrawBackgroundColor(RaceCountDownText,0x000000ff);
	TextDrawFont(RaceCountDownText,3);
	TextDrawLetterSize(RaceCountDownText,0.399999,1.599999);
	TextDrawColor(RaceCountDownText,0x00ff00ff);
	TextDrawSetOutline(RaceCountDownText,1);
	TextDrawSetProportional(RaceCountDownText,1);
	TextDrawSetShadow(RaceCountDownText,1);

//=======================================================================Infobar
	infobar = TextDrawCreate(301.000000,437.000000," /exitdm - Exit A Deathmatch");
	TextDrawUseBox(infobar,1);
	TextDrawBoxColor(infobar,0x00000066);
	TextDrawTextSize(infobar,688.000000,680.000000);
	TextDrawAlignment(infobar,2);
	TextDrawBackgroundColor(infobar,0x00000000);
	TextDrawFont(infobar,1);
	TextDrawLetterSize(infobar,0.399999,1.000000);
	TextDrawColor(infobar,0xffffffff);
	TextDrawSetOutline(infobar,1);
	TextDrawSetProportional(infobar,1);
	TextDrawSetShadow(infobar,1);

//=========================================================================Clock
	GlobalMinute = random(60);
	GlobalHour = random(24);
	ClockText = TextDrawCreate(605.0,25.0,"00:00");
	TextDrawUseBox(ClockText, 0);
	TextDrawFont(ClockText, 3);
	TextDrawSetShadow(ClockText,0);
	TextDrawSetOutline(ClockText,2);
	TextDrawBackgroundColor(ClockText,0x000000FF);
	TextDrawColor(ClockText,0xFFFFFFFF);
	TextDrawAlignment(ClockText,3);
	TextDrawLetterSize(ClockText,0.5,1.6);

//=====================================================================ScreenBox
	flash = TextDrawCreate(0.0, 0.0, "_");
	TextDrawFont(flash, 1);
	TextDrawLetterSize(flash, 0.0, 50.0);
	TextDrawUseBox(flash, 1);
	TextDrawColor(flash, 0);

//=====================================================================HitMarker
	new hm[14];
	hm[0] =92,	hm[1] =' ',hm[2] ='/',hm[3] ='~',hm[4] ='n',hm[5] ='~',	hm[6] =' ',
	hm[7] ='~',	hm[8] ='n',hm[9] ='~',hm[10]='/',hm[11]=' ',hm[12]=92,  hm[13]=EOS;
	//"\ /~n~ ~n~/ \"
	HitMark						=TextDrawCreate(317.000000,165.000000,hm);
	TextDrawAlignment			(HitMark,0);
	TextDrawBackgroundColor		(HitMark,0xffffff00);
	TextDrawFont				(HitMark,3);
	TextDrawLetterSize			(HitMark,1.000000,1.000000);
	TextDrawColor				(HitMark,0xffffff77);

//=====================================================================Animation
	txtAnimHelper = TextDrawCreate(610.0, 400.0, "~b~~k~~PED_LOCK_TARGET~ ~w~to stop the animation");
	TextDrawUseBox(txtAnimHelper, 0);
	TextDrawFont(txtAnimHelper, 2);
	TextDrawSetShadow(txtAnimHelper,0);
    TextDrawSetOutline(txtAnimHelper,1);
    TextDrawBackgroundColor(txtAnimHelper,0x000000FF);
    TextDrawColor(txtAnimHelper,0xFFFFFFFF);
    TextDrawAlignment(txtAnimHelper,3);

//====================================================================Race Lobby
	RaceCountDownText = TextDrawCreate(490.000000, 110.000000, "Race Starting In 30");
	TextDrawBackgroundColor(RaceCountDownText, 255);
	TextDrawFont(RaceCountDownText, 1);
	TextDrawLetterSize(RaceCountDownText, 0.400000, 1.399999);
	TextDrawColor(RaceCountDownText, -65281);
	TextDrawSetOutline(RaceCountDownText, 0);
	TextDrawSetProportional(RaceCountDownText, 1);
	TextDrawSetShadow(RaceCountDownText, 1);

//===============================================================Countdown Timer
	CountdownText = TextDrawCreate(70, 250, "00:00");
	TextDrawTextSize(CountdownText,636.000000,824.000000);
	TextDrawAlignment(CountdownText, 2);
	TextDrawFont(CountdownText,3);
	TextDrawLetterSize(CountdownText,0.499999,1.800000);
	TextDrawColor(CountdownText,0xffffffff);
	TextDrawSetProportional(CountdownText,2);
	TextDrawSetShadow(CountdownText,1);
	TextDrawSetOutline(CountdownText, 1);

//=============================================================FreeDM Scoreboard
	FreeDMScore = TextDrawCreate(20.000000, 140.000000, "~b~Score Board~n~~n~~g~Southclaw: 999~n~Cagatay: -69");
	TextDrawBackgroundColor(FreeDMScore, -1);
	TextDrawFont(FreeDMScore, 1);
	TextDrawLetterSize(FreeDMScore, 0.300000, 1.000000);
	TextDrawColor(FreeDMScore, -1);
	TextDrawSetOutline(FreeDMScore, 0);
	TextDrawSetProportional(FreeDMScore, 1);
	TextDrawSetShadow(FreeDMScore, 0);
	TextDrawUseBox(FreeDMScore, 1);
	TextDrawBoxColor(FreeDMScore, 120);
	TextDrawTextSize(FreeDMScore, 129.000000, -6.000000);

//===============================================================Looped Creation
	for(new playerid;playerid<MAX_PLAYERS;playerid++)
	{
		XPbar[playerid] 		=CreateProgressBar(220.0, 420.0, 350.0, 4.0, 0xFFFF0066);
		TankHeatBar[playerid]	=CreateProgressBar(220.0, 380.0, 200.0, 20.0, RED, 30.0);
		BleedoutBar[playerid]   =CreateProgressBar(220.0, 350.0, 200.0, 30.0, RED, 30.0);

		HealthCount[playerid]	=TextDrawCreate(577.000000, 66.000000, "100hp");
		TextDrawAlignment		(HealthCount[playerid], 2);
		TextDrawBackgroundColor	(HealthCount[playerid], -1);
		TextDrawFont			(HealthCount[playerid], 1);
		TextDrawLetterSize		(HealthCount[playerid], 0.439999, 1.000000);
		TextDrawColor			(HealthCount[playerid], -16776961);
		TextDrawSetOutline		(HealthCount[playerid], 0);
		TextDrawSetProportional	(HealthCount[playerid], 1);
		TextDrawSetShadow		(HealthCount[playerid], 0);
		TextDrawUseBox			(HealthCount[playerid], 1);
		TextDrawBoxColor		(HealthCount[playerid], 255);
		TextDrawTextSize		(HealthCount[playerid], 655.000000, 60.000000);

		SpecialWeps[playerid] 	=TextDrawCreate(497.000000,120.000000,"Equipment");
		TextDrawFont			(SpecialWeps[playerid],1);
		TextDrawLetterSize		(SpecialWeps[playerid],0.499999,1.500000);
		TextDrawColor			(SpecialWeps[playerid],0xffffffff);

		XPtext[playerid]		=TextDrawCreate(160.000000, 230.000000, "<XP>");
		TextDrawBackgroundColor	(XPtext[playerid], 255);
		TextDrawFont			(XPtext[playerid], 1);
		TextDrawLetterSize		(XPtext[playerid], 0.300000, 1.000000);
		TextDrawSetProportional	(XPtext[playerid], 1);
		TextDrawSetShadow		(XPtext[playerid], 1);
/*
		XPtext[playerid]		=TextDrawCreate(150.0,230.0," ");
		TextDrawTextSize		(XPtext[playerid],50.0,30.0);
		TextDrawFont			(XPtext[playerid],3);
		TextDrawLetterSize		(XPtext[playerid],1.0,2.5);
		TextDrawColor			(XPtext[playerid],YELLOW);
		TextDrawSetOutline      (XPtext[playerid],1);
*/
		MsgBox[playerid]		=TextDrawCreate(20.0, 160.0,"_");
		TextDrawUseBox			(MsgBox[playerid],1);
		TextDrawBoxColor		(MsgBox[playerid],0x00000033);
		TextDrawTextSize		(MsgBox[playerid],300,300);
		TextDrawFont			(MsgBox[playerid],1);
		TextDrawLetterSize		(MsgBox[playerid],0.499999,1.600000);
		TextDrawSetShadow		(MsgBox[playerid],0);

		RaceDistanceCount[playerid]=TextDrawCreate(490.0, 250.0, "Distance To Finish: 1000.00m");
		TextDrawBackgroundColor	(RaceDistanceCount[playerid], 255);
		TextDrawFont			(RaceDistanceCount[playerid], 1);
		TextDrawLetterSize		(RaceDistanceCount[playerid], 0.400000, 1.399999);
		TextDrawColor			(RaceDistanceCount[playerid], -1);
		TextDrawSetOutline		(RaceDistanceCount[playerid], 0);
		TextDrawSetProportional	(RaceDistanceCount[playerid], 1);
		TextDrawSetShadow		(RaceDistanceCount[playerid], 1);
		TextDrawUseBox			(RaceDistanceCount[playerid], 1);
		TextDrawBoxColor		(RaceDistanceCount[playerid], 100);
		TextDrawTextSize		(RaceDistanceCount[playerid], 620.0, 0.0);
 	}
}
LoadMenus()
{
	print("- Loading Menus...");
	script_CarMenu_LoadMenu();
	script_WepMenu_LoadMenu();
	script_MAP02_LoadItems();
//=======================================================================Weather
	weathermenu=CreateMenu("Weather", 1, 80.0, 80.0, 200.0, 300.0);

	AddMenuItem(weathermenu, 0, "Sunny");
	AddMenuItem(weathermenu, 0, "Cloudy");
	AddMenuItem(weathermenu, 0, "Stormy");
	AddMenuItem(weathermenu, 0, "Foggy");
	AddMenuItem(weathermenu, 0, "Sandstorm");
	AddMenuItem(weathermenu, 0, "Long Draw Distance");
	AddMenuItem(weathermenu, 0, "Random");
	AddMenuItem(weathermenu, 0, "Enter Weather ID");

//====================================================================TeamSelect
	TeamSelect = CreateMenu("Team", 1, 32.0, 170.0, 150.0);
	AddMenuItem(TeamSelect,0, "Raven");
	AddMenuItem(TeamSelect,0, "Valor");

//======================================================================Kit Menu
	KitSelect = CreateMenu("Kit", 1, 32.0, 170.0, 150.0);

	AddMenuItem(KitSelect, 0, "Assault");
	AddMenuItem(KitSelect, 0, "Medic");
	AddMenuItem(KitSelect, 0, "Sniper");
	AddMenuItem(KitSelect, 0, "Engineer");
	AddMenuItem(KitSelect, 0, "Kit Info");

//====================================================================Lobby Menu
	LobbyMenu = CreateMenu("~b~Get Ready", 1, 32.0, 170.0, 200.0);
	AddMenuItem(LobbyMenu, 0, "Select Team");
	AddMenuItem(LobbyMenu, 0, "Select Kit");
	AddMenuItem(LobbyMenu, 0, "Select Gear");
	AddMenuItem(LobbyMenu, 0, "Select Spawn (CQST)");
	AddMenuItem(LobbyMenu, 0, "Deathmatch Help");
	AddMenuItem(LobbyMenu, 0, "Spectate");
	AddMenuItem(LobbyMenu, 0, "~y~Ready");

//=====================================================================Minigames
	m_Minigame = CreateMenu("~b~Join Minigame", 1, 20, 170, 150);
	AddMenuItem(m_Minigame, 0, "Destruction Derby Brawl");
	AddMenuItem(m_Minigame, 0, "Sumo Cars");
	AddMenuItem(m_Minigame, 0, "Good Ol' Game Of Tag!");
	AddMenuItem(m_Minigame, 0, "Better Tag, With Guns!");
	AddMenuItem(m_Minigame, 0, "Fun With Rockets!");
	AddMenuItem(m_Minigame, 0, "Fun With Miniguns!");
	AddMenuItem(m_Minigame, 0, "Fun With Desert Eagles!");
	AddMenuItem(m_Minigame, 0, "Fun With Shotguns!");

//=======================================================================DMmaker
	DMcreate = CreateMenu("Create DM", 1, 32.0, 170.0, 150.0);
	AddMenuItem(DMcreate, 0, "Team 1 Spawn Point");
	AddMenuItem(DMcreate, 0, "Team 2 Spawn Point");
	AddMenuItem(DMcreate, 0, "Weather");
	AddMenuItem(DMcreate, 0, "Time");
	AddMenuItem(DMcreate, 0, "Start DM");
}
/*
LoadOldHouses()
{
	print("- Loading OLD Houses...");
	//Summer Drive, North Las Venturas, San Andreas
	{
		AddHouse("1 Summer Drive",  "SD1",  14000, 2049.653320, 2763.444580, 10.0, 2, 10000, 2057.069335, 2754.332031, 10.0);
		AddHouse("2 Summer Drive",  "SD2",  14000, 2066.138183, 2723.037841, 10.0, 5, 10000, 2033.261352, 2755.178466, 10.0);
		AddHouse("3 Summer Drive",  "SD3",  14000, 2039.724975, 2765.036865, 10.0, 2, 10000, 2031.813964, 2754.570068, 10.0);
		AddHouse("4 Summer Drive",  "SD4",  14000, 2037.259521, 2722.340332, 11.0, 4, 10000, 2028.122436, 2731.978027, 10.0);
		AddHouse("5 Summer Drive",  "SD5",  14000, 2018.782714, 2765.073974, 10.0, 8, 10000, 2011.504516, 2753.634765, 10.0);
		AddHouse("6 Summer Drive",  "SD6",  14000, 2018.124511, 2722.803710, 10.0, 7, 10000, 2010.702880, 2730.127441, 10.0);
		AddHouse("7 Summer Drive",  "SD7",  14000, 1992.550292, 2763.040771, 10.0, 3, 10000, 1997.383422, 2757.815673, 10.0);
		AddHouse("8 Summer Drive",  "SD8",  14000, 1969.901000, 2723.905029, 10.0, 6, 10000, 1960.840698, 2733.124267, 10.0);
		AddHouse("9 Summer Drive",  "SD9",  14000, 1967.520874, 2765.250244, 10.0, 4, 10000, 1960.571655, 2753.040283, 10.0);
		AddHouse("10 Summer Drive", "SD10", 14000, 1950.571777, 2724.289550, 10.0, 2, 10000, 1943.610961, 2731.471191, 10.0);
		AddHouse("11 Summer Drive", "SD11", 14000, 1928.170166, 2774.413574, 10.0, 5, 10000, 1925.431518, 2731.990966, 10.0);
		AddHouse("12 Summer Drive", "SD12", 14000, 1931.176147, 2722.862792, 10.0, 6, 10000, 1916.149536, 2760.633544, 10.0);
		AddHouse("13 Summer Drive", "SD13", 14000, 1921.383422, 2661.242187, 10.0, 4, 10000, 1928.208496, 2652.848388, 10.0);
		AddHouse("14 Summer Drive", "SD14", 14000, 1950.580566, 2662.506835, 10.0, 2, 10000, 1959.198364, 2652.283447, 10.0);
		AddHouse("15 Summer Drive", "SD15", 14000, 1969.625122, 2662.983154, 10.0, 4, 10000, 1977.447265, 2654.149658, 10.0);
		AddHouse("16 Summer Drive", "SD16", 14000, 1989.005615, 2663.219726, 10.0, 6, 10000, 1995.788330, 2653.649414, 10.0);
		AddHouse("17 Summer Drive", "SD17", 14000, 2017.901245, 2662.665039, 10.0, 7, 10000, 2027.006347, 2652.186767, 10.0);
		AddHouse("18 Summer Drive", "SD18", 14000, 2036.945800, 2662.374267, 10.0, 4, 10000, 2044.532592, 2653.449462, 10.0);
		AddHouse("19 Summer Drive", "SD19", 14000, 2056.506103, 2663.149902, 10.0, 7, 10000, 2063.164306, 2651.945800, 10.0);
	}
}
*/
LoadRaces()
{
	print("- Loading Races...");
	new
		File:idxFile=fopen(RaceIndexFile, io_read),
		line[128],
		Float:cp_x,
		Float:cp_y,
		Float:cp_z,
		file[50];
	while(fread(idxFile, line))
	{
		if(!sscanf(line, "p<,>s[50]fff", file, cp_x, cp_y, cp_z))
		{
			new
				id,
				tag[128];
			while(RaceIdUsed[id])id++;
			format(RaceFile[id], 50, RaceDataFile, file);
			file_Open(RaceFile[id]);
			RaceFinishLocation=file_GetVal("FinishPos");
			if(file_IsKey("bestP"))
			{
			    format(BestP, 24, file_GetStr("bestP"));
			    BestM=file_GetVal("bestM");
			    BestS=file_GetVal("bestS");
			    BestMS=file_GetVal("bestMS");
				format(BestTime, 15, "%02d:%02d.%02d", BestM, BestS, BestMS);
				format(tag, 128, "%s\n%s - %s\n\nFinish: %s", file, BestP, BestTime, RaceFinish[RaceFinishLocation]);
			}
			else format(tag, 128, "%s\n\nFinish: %s", file, RaceFinish[RaceFinishLocation]);
			file_Close();

			JoinLabel[id]=CreateDynamic3DTextLabel(tag, YELLOW, cp_x, cp_y, cp_z, 100.0);

			JoinCP[id]=CreateDynamicRaceCP(2, cp_x, cp_y, cp_z, 0, 0, 0, 5.0, FREEROAM_WORLD);
			for(new i;i<MAX_RACE_PLAYERS;i++)SlotUsage[i]=-1;
			RaceIdUsed[id]=true;
			TotalRaces++;
		}
		else print("Error: Race File Index");
	}
	fclose(idxFile);
}
LoadDeathmatches()
{
	print("- Loading Deathmatches...");
	new
		File:idxFile=fopen(DMIndexFile, io_read),
		idx,
		line[160];
	while(fread(idxFile, line))
	{
		if(sscanf(line, "p<|>s[20]bds[128]s[14]s[26]", MapNames[idx], MapModes[idx], MapRegion[idx], MapInfo_Bio[idx], MapInfo_Size[idx], MapInfo_Kit[idx]))print("Error: Deathmatch File Index");
/*
		new File1[128],File2[128];
		format(File1, 128, dmMapFile, idx, MapNames[idx]);
		format(File2, 128, "Converted Maps/%d-%s.pwn", idx, MapNames[idx]);

		new
			File:F1=fopen(File1, io_read),
			File:F2=fopen(File2, io_write),
			str1[256],
			str2[256];
		while(fread(F1, str1))
		{
		    strdel(str1, (strlen(str1)-3), strlen(str1));
		    format(str2, 256, "CreateObject(%s);\r\n", str1);
		    fwrite(F2, str2);
		}
		fclose(F1);
		fclose(F2);
*/
		++idx;
	}
	fclose(idxFile);


	for(new r;r<5;r++)
	{
	    idx=0;
		format(RegionMenu, 60, "%s%s\n", RegionMenu, RegionNames[r]);
		for(new m;m<MAX_MAPS;m++)
		{
			if(MapRegion[m]==r)
			{
				format(RegionMaps[r], 200, "%s%s\n", RegionMaps[r], MapNames[m]);
				RegionItems[m]=idx;
				idx++;
			}
		}
		strcat(RegionMaps[r], "Back");
	}
	strcat(RegionMenu, "Close");
}

new
	CaveLift,
	CaveLiftButtonT,
	CaveLiftButtonB,
	LiftPos,

	fSC_DoorOpen1,
	fSC_DoorOpen2,
	fSC_DoorObj;

LoadButtons()
{
	print("- Loading Buttons...");
	new
		tpID1,
		tpID2;

	tpID1=CreateButton(-217.913787, 1402.804199, 26.0, "Press F to enter");
	tpID2=CreateButton(-101.579933, 1374.613769, 9.0, "Press F to enter");
	LinkTP(tpID1, tpID2);

// ABD World Stuff


	// Subway/Metro interior 1=inside 2=surface

	tpID1=CreateButton(-1007.395263, 5782.741210, 42.951477, "Press F to climb up the ladder", ABD_WORLD);
	tpID2=CreateButton(2526.719482, -1648.620605, 14.471982, "Press F to climb down the ladder", ABD_WORLD);
	LinkTP(tpID1, tpID2);

	tpID1=CreateButton(250.599380, -154.643936, -50.768798, "Press F to enter", ABD_WORLD);
	tpID2=CreateButton(247.878799, -154.444061, 02.399550, "Press F to enter", ABD_WORLD);
	LinkTP(tpID1, tpID2);

	tpID1=CreateButton(-2276.608642, 5324.488281, 41.677970, "Press F to enter", ABD_WORLD);
	tpID2=CreateButton(-734.773986, 3861.994628, 12.482711, "Press F to enter", ABD_WORLD); // cave
	LinkTP(tpID1, tpID2);
	
	// Quarry

	tpID1=CreateButton(-2702.358398, 3801.477050, 52.652801, "Press F enter", ABD_WORLD); // cave 1
	tpID2=CreateButton(495.451873, 780.096191, -21.747426, "Press F enter", FREEROAM_WORLD); // quarry
	LinkTP(tpID1, tpID2);

	tpID1=CreateButton(-2796.933349, 3682.779785, 02.515481, "Press F to enter", ABD_WORLD); // cave 1
	tpID2=CreateButton(-785.9272, 3727.1111, 0.5293, "Press F to enter", ABD_WORLD); // cave 2
	LinkTP(tpID1, tpID2);

	// Fort Claw underground

	tpID1=CreateButton(246.698684, -178.849655, -50.199367, "Press F to enter", ABD_WORLD); // underground
	tpID2=CreateButton(-952.559326, 5137.799804, 46.183383, "Press F to enter", ABD_WORLD); // metro station
	LinkTP(tpID1, tpID2);
	
	CreateButton(-972.153869, 4303.185058, 48.666248, "~r~Locked", ABD_WORLD);

	// Lift Sequence

	CaveLiftButtonT=CreateButton(-2763.920166, 3757.585693, 47.112922, "Press F to use the lift", ABD_WORLD);
	CaveLiftButtonB=CreateButton(-2762.859130, 3755.092529, 8.238883, "Press F to use the lift", ABD_WORLD);
	CaveLift=CreateDynamicObject(7246, -2759.4704589844, 3756.869140625, 6.9, 270, 180, 340.91540527344, ABD_WORLD);
	LiftPos=0;
	
	// Fort Claw Door
	
	fSC_DoorOpen1=CreateButton(264.316284, -171.135223, -50.206447, "Press F to activate", ABD_WORLD);
	fSC_DoorOpen2=CreateButton(265.862182, -170.113632, -50.204307, "Press F to activate", ABD_WORLD);
	fSC_DoorObj=CreateDynamicObject(5779, 265.03302001953, -168.93629455566, -49.979248046875, 0, 0, 0, ABD_WORLD, 0, -1, MAX_RENDER_DISTANCE);


// Deathmatch Stuff
	tpID1 = CreateButton(-1280.388549, -141.772979, 721.0, "Press F to enter", DEATHMATCH_WORLD);
	tpID2 = CreateButton(-1278.898193, -141.713790, 721.0, "Press F to enter", DEATHMATCH_WORLD);
	LinkTP(tpID1, tpID2);

	tpID1 = CreateButton(-1337.346191, -143.784347, 721.0, "Press F to enter", DEATHMATCH_WORLD);
	tpID2 = CreateButton(-1337.411132, -145.632156, 721.0, "Press F to enter", DEATHMATCH_WORLD);
	LinkTP(tpID1, tpID2);

	tpID1 = CreateButton(-1392.069946, -15.105671, 713.0, "Press F to climb up", DEATHMATCH_WORLD);
	tpID2 = CreateButton(-1392.069946, -17.105671, 733.0, "Press F to climb down", DEATHMATCH_WORLD);
	LinkTP(tpID1, tpID2);

	OutskirtsElevator=CreateDynamicObject(18755, -1293.7974, -773.43, 215.1900, 0.0000, 0.0000, 270.0000, DEATHMATCH_WORLD);
	MAP23_ElevatorB=CreateButton(-1293.7974, -773.43, 215.1900, "Press F to activate", DEATHMATCH_WORLD);
	MAP23_ElevatorT=CreateButton(-1293.7974, -773.43, 223.79, "Press F to activate", DEATHMATCH_WORLD);
}
OnButtonPress(playerid, buttonid)
{
	script_Houses_OnButtonPress(playerid, buttonid);
    BaseDoorCheck(playerid, buttonid);
	for(new i;i<MAX_BALLOON;i++)
	{
		if(buttonid==BLN_Button[i][0] || buttonid==BLN_Button[i][1])
		{
		    if(buttonid==BLN_Button[i][BLN_CurrentPos[i]] && BLN_Frame[i]==BLN_FRAME_IDLE)
		    {
				BLN_Frame[i]=BLN_FRAME_LIFTOFF;
				MoveBalloon(i);
			}
			else ShowMsgBox(playerid, "Balloon isn't here yet", 3000);
			break;
		}
	}
	if(buttonid==CaveLiftButtonT)
	{
		if(LiftPos)
		{
		    MoveDynamicObject(CaveLift, -2759.4704589844, 3756.869140625, 6.9, 2.0, 270, 180, 340.9);
		    LiftPos=0;
		}
		else
		{
		    MoveDynamicObject(CaveLift, -2759.4704589844, 3756.869140625, 45.0, 2.0, 270, 180, 340.9);
		    LiftPos=1;
		}
	}
	if(buttonid==CaveLiftButtonB)
	{
		if(LiftPos)
		{
		    MoveDynamicObject(CaveLift, -2759.4704589844, 3756.869140625, 45.0, 2.0, 270, 180, 340.9);
		    LiftPos=0;
		}
		else
		{
		    MoveDynamicObject(CaveLift, -2759.4704589844, 3756.869140625, 6.9, 2.0, 270, 180, 340.9);
		    LiftPos=1;
		}
	}
	if(buttonid==fSC_DoorOpen1 || buttonid==fSC_DoorOpen2)
	{
		MoveDynamicObject(fSC_DoorObj, 265.0322, -168.9355, -46.8575, 1.8);
	    PlaySound(6400, 265.0322, -168.9355, -46.8575);
		PlaySound(6000, 265.0322, -168.9355, -46.8575);
		PlaySound(6002, 265.0322, -168.9355, -46.8575);

		SetTimerEx("DoorClose", 5000, false, "dd", fSC_DoorObj, playerid);
	}

	if(buttonid==MAP23_ElevatorT)
	{
		if(ElevatorPos)
		{
			MoveDynamicObject(OutskirtsElevator, -1293.7974, -773.43, 215.1900, 3.0);
			ElevatorPos=0;
		}
		else
		{
			MoveDynamicObject(OutskirtsElevator, -1293.7974, -773.43, 223.79, 3.0);
			ElevatorPos=1;
		}
	}
	if(buttonid==MAP23_ElevatorB)
	{
		if(ElevatorPos)
		{
			MoveDynamicObject(OutskirtsElevator, -1293.7974, -773.43, 223.79, 3.0);
			ElevatorPos=0;
		}
		else
		{
			MoveDynamicObject(OutskirtsElevator, -1293.7974, -773.43, 215.1900, 3.0);
			ElevatorPos=1;
		}
	}

	return 1;
}
public DoorClose(objectid, playerid)
{
	if(objectid==fSC_DoorObj)
	{
	    MoveDynamicObject(fSC_DoorObj, 265.03302001953, -168.93629455566, -49.979248046875, 1.8);
	    PlaySound(6400, 265.0322, -168.9355, -46.8575);
		PlaySound(6000, 265.0322, -168.9355, -46.8575);
		PlaySound(6002, 265.0322, -168.9355, -46.8575);
	}
}
public OnDynamicObjectMoved(objectid)
{
	for(new i;i<MAX_BALLOON;i++)if(objectid==BLN_Object[i])script_Balloon_ObjectMove(i);
	if(objectid==fSC_DoorObj)
	{
	    PlaySound(1063, 265.0322, -168.9355, -46.8575);
		PlaySound(6400, 265.0322, -168.9355, -46.8575);
	}
	return 1;
}







stock GetIpCountry(IpInfo[])
{
	new ReturnCountry[40];
	if(!strcmp("127.0.0.1",IpInfo,true))ReturnCountry="Localhost ";
	else
	{
		new File:IPFile=fopen(ipData, io_read);
		if(IPFile)
		{
		    new DataSetting[4][40];
			if(sscanf(IpInfo, "p<.>s[10]s[10]s[10]s[10]", DataSetting[0], DataSetting[1], DataSetting[2], DataSetting[3])){fclose(IPFile);ReturnCountry="Invalid IP";}
			else
			{
				new
					ipf=(16777216*strval(DataSetting[0]))+(65536*strval(DataSetting[1])) + (256*strval(DataSetting[2])) + strval(DataSetting[3]), // printf("ipf: %d",ipf);
	    			Text[256],
	    			count_1,
	    			count_2;

				while(fread(IPFile, Text))
				{
					count_1++;
					if(sscanf(Text, "p<,>s[20]s[20]s[40]", DataSetting[0], DataSetting[1], DataSetting[2])) { fclose(IPFile); format(ReturnCountry, sizeof ReturnCountry, "Error IPdata file, line %d", count_1); return ReturnCountry; }
   	    			if(ipf >= strval(DataSetting[0]) && ipf <= strval(DataSetting[1]))
					{
						format(ReturnCountry, sizeof ReturnCountry, "%s", DataSetting[2]);
						break;
	    			}
					else
					{
	    			    count_2++;
					}
				}
				if(count_1 == count_2) { ReturnCountry = "Unknown";}
			}
			fclose(IPFile);
		}
		else ReturnCountry = "Country File Not Found!";
	}
	return ReturnCountry;
}

stock GetPlayersOnline()
{
	new p;
	PlayerLoop(i)p++;
	return p;
}
stock SetMapName(MapName[])
{
	new str[30];
	format(str,30,"mapname %s",MapName);
	SendRconCommand(str);
}

msgAdmins(message[])PlayerLoop(i)if(IsPlayerAdmin(i)) msg(i, WHITE, message);


stock AddVehicleComponentEx(vehicleid, ...)
{
	new
		i,
		Component_ID,
		num = numargs();
	if(num > 11) num = 11;
	for(i = 1; i < num; i++)
	{
		Component_ID = getarg(i, 0);
		AddVehicleComponent(vehicleid, Component_ID);
	}
	return i-1;
}
stock GetRandomTeamPlayer(team)
{
	new result;
	PlayerLoop(i)
	{
	    result = random(MAX_PLAYERS);
		if(IsPlayerConnected(result)&&pTeam(result)==team)break;
	}
	return result;
}
stock GetPlayersInRangeOfPlayer(playerid, range)
{
	new Float:x, Float:y, Float:z, players;
	GetPlayerPos(playerid, x, y, z);
	PlayerLoop(i)if(IsPlayerInRangeOfPoint(i, range, x, y, z))players++;
	return players;
}
#define PreloadAnimLib(%1,%2) ApplyAnimation(%1,%2,"null",0.0,0,0,0,0,0)
PreloadPlayerAnims(playerid)
{
   	PreloadAnimLib(playerid,"BOMBER");
   	PreloadAnimLib(playerid,"RAPPING");
   	PreloadAnimLib(playerid,"SHOP");
	PreloadAnimLib(playerid,"BEACH");
	PreloadAnimLib(playerid,"SMOKING");
   	PreloadAnimLib(playerid,"FOOD");
   	PreloadAnimLib(playerid,"ON_LOOKERS");
   	PreloadAnimLib(playerid,"DEALER");
	PreloadAnimLib(playerid,"CRACK");
	PreloadAnimLib(playerid,"CARRY");
	PreloadAnimLib(playerid,"COP_AMBIENT");
	PreloadAnimLib(playerid,"PARK");
	PreloadAnimLib(playerid,"INT_HOUSE");
	PreloadAnimLib(playerid,"FOOD");
	PreloadAnimLib(playerid,"PED");
}
stock GetHighestID()
{
	new id;
	PlayerLoop(i)if(i>id)id=i;
	return id;
}
stock spec_ToggleDMSpec(playerid, bool:toggle)
{
	if(toggle)
	{
		TogglePlayerSpectating(playerid, true);
		ShowMsgBox(playerid, "~y~~<~~b~Switch Players~y~~>~");
		PlayerSpectating[playerid]=true;
		new i;
		while(!bPlayerGameSettings[i]&InDM&&!IsPlayerConnected(i)&&<MAX_PLAYERS)i++;
		if(bPlayerGameSettings[i]&InDM&&IsPlayerConnected(i)&&<MAX_PLAYERS)
		{
			PlayerSpectateTarget[playerid]=i;
			PlayerSpectatePlayer(playerid, i);
		}
	}
	else
	{
		HideMsgBox(playerid);
		TogglePlayerSpectating(playerid, false);
	}
}
stock spec_SwitchTarget(playerid, direction)
{
	if(PlayerSpectateTarget[playerid]!=-1)
	{
	    if(direction)
	    {
	    }
	    else
	    {
	    }
	}
	else return 0;
	return 0;
}
stock NoBadCam(playerid)
{
	new Float:x, Float:y, Float:z,Float:ang;
	GetPlayerCameraFrontVector(playerid, x, y, z);
	GetPlayerFacingAngle(playerid,ang);
	if((x < 0.0 && y > 0.0) && (ang > 90.0 && ang < 300.0)) return 0;
	else if((x > 0.0 && y > 0.0) && (ang > 88.16 && ang < 275.0)) return 0;
	else if((x < 0.0 && y < 0.0) && (ang > 257.30 && ang < 360.0)) return 0;
	else if((x > 0.0 && y < 0.0) && (ang < 88.16 && ang < 257.30)) return 0;
	return 1;
}
stock SpawnCarForPlayer(playerid, model, perma=1)
{
	if(perma==1 && (pAdmin(playerid)<=3))perma=0;
    new Float:x, Float:y, Float:z, Float:a, vw=GetPlayerVirtualWorld(playerid), in=GetPlayerInterior(playerid);

    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);

	if(IsPlayerInAnyVehicle(playerid))
	{
		new pv = GetPlayerVehicleID(playerid);
		DestroyVehicle(pv);
		if(pVehicle[playerid]==pv)pVehicle[playerid]=-1;
	}
	pVehicle[playerid]=CreateVehicle(model, x, y, z, a, -1, -1, 1000);
	SetVehicleVirtualWorld(pVehicle[playerid], vw);
	LinkVehicleToInterior(pVehicle[playerid], in);
	PutPlayerInVehicle(playerid, pVehicle[playerid], 0);
	v_Engine(pVehicle[playerid], 1);
	if(perma)pVehicle[playerid]=-1;

    TogglePlayerControllable(playerid, 1);
	msgF(playerid, YELLOW, "**%s Spawned", VehicleNames[model-400]);
}


#define chrtolower(%1) \
		(((%1) > 0x40 && (%1) <= 0x5A) ? ((%1) | 0x20) : (%1))
stock strtolower(string[])
{
	new retStr[128],i,j;
	while ((j = string[i])) retStr[i++] = chrtolower(j);
	retStr[i] = '\0';
	return retStr;
}
//class public delete break continue new if for while do goto const int float bool true false enum return try switch case default
new VehicleSeats[] =
{4,2,2,2,4,4,1,2,2,4,2,2,2,4,2,2,4,2,4,2,4,4,2,2,2,1,4,4,4,2,1,500,1,2,2,0,2,500,4,2,4,1,2,2,2,4,1,2,
1,0,0,2,1,1,1,2,2,2,4,4,2,2,2,2,1,1,4,4,2,2,4,2,1,1,2,2,1,2,2,4,2,1,4,3,1,1,1,4,2,2,4,2,4,1,2,2,2,4,
4,2,2,1,2,2,2,2,2,4,2,1,1,2,1,1,2,2,4,2,2,1,1,2,2,2,2,2,2,2,2,4,1,1,1,2,2,2,2,500,500,1,4,2,2,2,2,2,
4,4,2,2,4,4,2,1,2,2,2,2,2,2,4,4,2,2,1,2,4,4,1,0,0,1,1,2,1,2,2,1,2,4,4,2,4,1,0,4,2,2,2,2,0,0,500,2,2,
1,4,4,4,2,2,2,2,2,4,2,0,0,0,4,0,0};
stock GetVehicleMaxSeats(modelid) return VehicleSeats[(GetVehicleModel(modelid)-400)];
stock GetMoney(i)return GetPlayerMoney(i);
stock GetHealth(i){new Float:h;GetPlayerHealth(i,h);return h;}
stock GetArmour(i){new Float:a;GetPlayerArmour(i,a);return a;}

HighestOnlineAdmin()
{
	new id;
	PlayerLoop(i)if(pAdmin(i)>pAdmin(id))id=i;
	return id;
}



stock Float:ph_Velocity(Float:distance, timetaken)
		return(distance/timetaken); // Meters per Second (m/s)
stock Float:ph_Acceleration(Float:velocitychange, timetaken) // (vfinal - vinitial) / (tfinal - tinitial)
		return(velocitychange/timetaken); // Meters per Second Squared (m/s^2)
stock Float:ph_Force(Float:mass, Float:acceleration)
		return(mass*acceleration); // Newtons (N)
stock Float:ph_Momentum(Float:mass, Float:velocity)
		return(mass*velocity); // Kilograms per Meter per Second (kgm/s)
stock Float:ph_ImpactForce(Float:momentum, timetaken)
		return(momentum/timetaken); // Newtons (N)

stock StringBinToVal(str[])
{
	new
		len=(strlen(str)-1),
		var,
		varold;
	for(new i = len, x = 0; i >= 0 && x <= len; i--, x++)
	{
		var = floatround(((str[x]-48)*floatpower(2, i)) + varold);
		varold=var;
	}
	return var;
}
Numerical(val)
{
	new str[4], c[3];
	switch(val)
	{
	    case 1:c="st";
	    case 2:c="nd";
	    case 3:c="rd";
	    default:c="th";
	}
	format(str, 4, "%d%s", val, c);
	return str;
}

stock filterColorTags(string[], bool: gxtTags, bool: sampColors)
{
    if(gxtTags)
    {
        new textPos = -1;
        while((textPos = strfind(string, "~", false, (textPos + 1))) != -1)
        {
            switch((string[textPos + 1] = tolower(string[textPos + 1])))
            {
                case 'r', 'g', 'b', 'w', 'y', 'p', 'l', 'n', 'h', '<', '>':
                {
                    if(string[textPos + 2] == '~')
                    {
                        strdel(string, textPos, (textPos + 3));
                    }
                }
                default: continue;
            }
        }
    }
    if(sampColors)
    {
        new
            textPos = -1,
            i;
        while((textPos = strfind(string, "{", false, (textPos + 1))) != -1)
        {
            for(i = textPos; i != (textPos + 7); ++i)
            {
                switch(string[i])
                {
                    case 'a'..'f', 'A'..'F', '0'..'9':
                    {
                        if(i == (textPos + 6))
                        {
                            if(string[(i + 1)] == '}')
                            {
                                strdel(string, textPos, (i + 2));
                            }
                        }
                    }
                    default: continue;
                }
            }
        }
    }
    return ;
}

stock GetPlayerCameraFrontVector_Ex(Float:radius, Float:Phi, Float:Lambda, &Float:x, &Float:y, &Float:z)
{
    x = radius * floatcos(-Phi, degrees) * floatsin(-Lambda, degrees);
    y = radius * floatcos(-Phi, degrees) * floatcos(-Lambda, degrees);
    z = radius * floatsin(-Phi, degrees);
}


stock GameTextStr(str[])
{
	new start, end;
	start=strfind(str, "[");
	end=strfind(str, "]");
	if(start!=-1&&end!=-1)strdel(str, start, end);
	return str;
}

LoadVehiclesFromFile(file[])
{
	if(!fexist(file))return print("VEHICLE FILE NOT FOUND");
	new
	    File:F=fopen(file, io_read),
		line[128],
		Model,
		Pos[4],
		Colour[2];
	while(fread(F, line))
	{
		if(sscanf(line, "p<,>dffffdd", Model, Pos[0], Pos[1], Pos[2], Pos[3], Colour[0], Colour[1]))print("LINE ERROR");
		else AddStaticVehicle(Model, Pos[0], Pos[1], Pos[2], Pos[3], Colour[0], Colour[1]);
	}
	print("Vehicles loaded from file");
	return 0;
}
